def find_file_dir_up(filename, path=None, n=None):
if path is None:<EOL><INDENT>path = os.getcwd()<EOL><DEDENT>i = <NUM_LIT:0><EOL>while True:<EOL><INDENT>current_path = path<EOL>for _ in range(i):<EOL><INDENT>current_path = os.path.split(current_path)[<NUM_LIT:0>]<EOL><DEDENT>if os.path.isfile(os.path.join(current_path, filename)):  <EOL><INDENT>return os.path.join(current_path, filename)<EOL><DEDENT>elif os.path.dirname(current_path) == current_path:  <EOL><INDENT>return<EOL><DEDENT>elif n is not None and i == n:<EOL><INDENT>return<EOL><DEDENT>else:  <EOL><INDENT>i += <NUM_LIT:1><EOL>continue<EOL><DEDENT><DEDENT>
Finding file in directory upwards.