'Converts a list of privileges to a hierarchical tree of privileges by object, where the privilege is stored into a
key named SENTRY_PRIVILEGE_KEY.
NOTE: This assumes no objects share the same name as SENTRY_PRIVILEGE_KEY'

def _to_privilege_hierarchy_v1(self, privileges):

    tree = (lambda : defaultdict(tree))
    hierarchy = tree()
    for privilege in privileges:
        (column, table, database, server, uri) = (privilege.get('column'), privilege.get('table'), privilege.get('database'), privilege.get('server'), privilege.get('URI'))
        if column:
            hierarchy[server][database][table][column][SENTRY_PRIVILEGE_KEY] = privilege
        elif table:
            hierarchy[server][database][table][SENTRY_PRIVILEGE_KEY] = privilege
        elif database:
            hierarchy[server][database][SENTRY_PRIVILEGE_KEY] = privilege
        elif uri:
            hierarchy[server][uri][SENTRY_PRIVILEGE_KEY] = privilege
        else:
            hierarchy[server][SENTRY_PRIVILEGE_KEY] = privilege
    return hierarchy
