@Override
    public ResultPage<FindResultWithPermissions> advancedFindWithPermissions(
            final AdvancedDocumentFindWithPermissionsRequest request) {
        // First find the results then decorate them with user permissions.
        final List<FindResultWithPermissions> results = new ArrayList<>();
        applyExpressionFilter(request, (path, node) -> {
            final FetchDocumentUserPermissionsRequest fetchDocumentUserPermissionsRequest =
                    new FetchDocumentUserPermissionsRequest.Builder()
                            .userRef(request.getUserRef())
                            .showLevel(request.getShowLevel())
                            .docRef(node.getDocRef())
                            .build();
            final ResultPage<DocumentUserPermissions> permissions = documentPermissionService
                    .fetchDocumentUserPermissions(fetchDocumentUserPermissionsRequest);
            if (!permissions.isEmpty()) {
                final DocumentUserPermissions documentUserPermissions = permissions.getFirst();
                results.add(new FindResultWithPermissions(createFindResult(path, node), documentUserPermissions));
            }
            return true;
        });

        // If this is recent items mode then filter by recent items.
        results.sort(Comparator
                .<FindResultWithPermissions, String>comparing(res ->
                        res.getFindResult().getDocRef().getName(), Comparator.naturalOrder())
                .thenComparing(res -> res.getFindResult().getPath())
                .thenComparing(res -> res.getFindResult().getDocRef().getType())
                .thenComparing(res -> res.getFindResult().getDocRef().getUuid()));

        // Return the decorated result.
        return ResultPage.createPageLimitedList(results, request.getPageRequest());
    }
Create a map of folders and their child items.
stroom-explorer/stroom-explorer-impl/src/main/java/stroom/explorer/impl/ExplorerServiceImpl.java