def search_tree(root, glob_match, ext='', exts=None, dir_ext=None):
 exts = (exts or [ext])
 found_files = []
 for path in glob.glob(os.path.join(root, glob_match)):
  if os.path.isdir(path):
   for (root, dirs, files) in os.walk(path):
    if (dir_ext and root.endswith(dir_ext)):
     found_files.append(root)
     break
    for file_ in files:
     if (any(exts) and (not any((file_.endswith(e) for e in exts)))):
      continue
     found_files.append(os.path.join(root, file_))
    found_dir = False
    for dir_ in dirs:
     if (dir_ext and dir_.endswith(dir_ext)):
      found_dir = True
      found_files.append(os.path.join(root, dir_))
    if found_dir:
     break
  else:
   if (ext and (not path.endswith(ext))):
    continue
   found_files.append(path)
 return sorted(found_files)

def search_tree ( root , glob_match , ext = '' , exts = None , dir_ext = None ) : exts = ( exts or [ ext ] ) found_files = [ ] for path in glob . glob ( os . path . join ( root , glob_match ) ) : if os . path . isdir ( path ) : for ( root , dirs , files ) in os . walk ( path ) : if ( dir_ext and root . endswith ( dir_ext ) ) : found_files . append ( root ) break for file_ in files : if ( any ( exts ) and ( not any ( ( file_ . endswith ( e ) for e in exts ) ) ) ) : continue found_files . append ( os . path . join ( root , file_ ) ) found_dir = False for dir_ in dirs : if ( dir_ext and dir_ . endswith ( dir_ext ) ) : found_dir = True found_files . append ( os . path . join ( root , dir_ ) ) if found_dir : break else : if ( ext and ( not path . endswith ( ext ) ) ) : continue found_files . append ( path ) return sorted ( found_files )
look in root .