def METHOD_NAME(path):
    """Given a path return the closes existing directory. Either itself
    or a parent. In case it can't find one it returns None.
    Returns:
        fsnative or None
    """
    path = os.path.abspath(path)
    def is_ok(p):
        return os.path.exists(p) and os.path.isdir(p)
    while not is_ok(path):
        dirname = os.path.dirname(path)
        if dirname == path:
            return None
        path = dirname
    return path