'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_v2(self, privileges):

    tree = (lambda : defaultdict(tree))
    hierarchy = tree()
    for privilege in privileges:
        (component, service, authorizables) = (privilege['component'], privilege['serviceName'], privilege['authorizables'])
        for obj in authorizables:
            (object_type, object_name) = (obj.get('type'), obj.get('name'))
            hierarchy[component][service][object_type][object_name][SENTRY_PRIVILEGE_KEY] = privilege
    return hierarchy
