def _Dirname(path):
    """Returns the parent directory of path."""
    i = path.rfind("/") + 1
    head = path[:i]
    if head and head != "/" * len(head):
        head = head.rstrip("/")
    return head