if func(os.path.join(start, stop)):
    return start
elif os.path.samefile(start, os.path.dirname(start)):
    return None
else:
    return _find_root(os.path.dirname(start), stop)
Check if a directory is a (file system) root