def find_dir(p):
 x = 'x'
 while (x and (not os.path.exists(p))):
  (p, x) = os.path.split(p)
 return p

def find_dir ( p ) : x = 'x' while ( x and ( not os . path . exists ( p ) ) ) : ( p , x ) = os . path . split ( p ) return p
return first folder level that exists in this path .