def find_candidates_in_parent_dirs(filenames, path):
 candidates = [filename for filename in filenames if os.path.exists(os.path.join(path, filename))]
 if (not candidates):
  parent_dir = os.path.join(path, u'..')
  if (os.path.abspath(parent_dir) != os.path.abspath(path)):
   return find_candidates_in_parent_dirs(filenames, parent_dir)
 return (candidates, path)

def find_candidates_in_parent_dirs ( filenames , path ) : candidates = [ filename for filename in filenames if os . path . exists ( os . path . join ( path , filename ) ) ] if ( not candidates ) : parent_dir = os . path . join ( path , u'..' ) if ( os . path . abspath ( parent_dir ) != os . path . abspath ( path ) ) : return find_candidates_in_parent_dirs ( filenames , parent_dir ) return ( candidates , path )
given a directory path to start .