Gets the directory path of the given path name. If the argument 'greedy'
    is specified as True, then if the path name represents a directory itself,
    the function will return the whole path

def get_dir(path_name, *, greedy=False, override=None, identity=None):
    """
    Gets the directory path of the given path name. If the argument 'greedy'
    is specified as True, then if the path name represents a directory itself,
    the function will return the whole path
    """
    if identity is None:
        identity = identify(path_name, override=override)

    path_name = os.path.normpath(path_name)

    if greedy and identity == ISDIR:
        return path_name
    else:
        return os.path.dirname(path_name)