private static Set<ResourceAccessType> lookupPermissions(
            ResourceDescriptor resource,
            Map<String, Set<ResourceAccessType>> resourcePermissions,
            Map<ResourceDescriptor, Set<ResourceAccessType>> cache) {
        if (resource == null) {
            return Set.of();
        }

        Set<ResourceAccessType> permissions = cache.get(resource);
        if (permissions == null) {
            permissions = Sets.union(
                    resourcePermissions.getOrDefault(resource.getUrl(), Set.of()),
                    lookupPermissions(resource.getParent(), resourcePermissions, cache));
            cache.put(resource, permissions);
        }

        return permissions;
    }
Accept an invitation to grand share access for provided resources

@param invitationId - invitation ID
server/src/main/java/com/epam/aidial/core/server/service/ShareService.java