def walk_up(bottom):
bottom = os.path.realpath(bottom)<EOL>try:<EOL><INDENT>names = os.listdir(bottom)<EOL><DEDENT>except Exception:<EOL><INDENT>return<EOL><DEDENT>dirs, nondirs = [], []<EOL>for name in names:<EOL><INDENT>if os.path.isdir(os.path.join(bottom, name)):<EOL><INDENT>dirs.append(name)<EOL><DEDENT>else:<EOL><INDENT>nondirs.append(name)<EOL><DEDENT><DEDENT>yield bottom, dirs, nondirs<EOL>new_path = os.path.realpath(os.path.join(bottom, '<STR_LIT:..>'))<EOL>if new_path == bottom:<EOL><INDENT>return<EOL><DEDENT>for x in walk_up(new_path):<EOL><INDENT>yield x<EOL><DEDENT>
mimic os.walk, but walk 'up' instead of down the directory tree.
    From: https://gist.github.com/zdavkeos/1098474