private void addDocRef(final DocRef docRef, final Set<DocRef> docRefs) {
        try {
            final ImportExportActionHandler importExportActionHandler = importExportActionHandlers.getHandler(
                    docRef.getType());
            if (importExportActionHandler != null) {
                if (securityContext.hasDocumentPermission(docRef, DocumentPermission.VIEW)) {
                    docRefs.add(docRef);

                    final Set<DocRef> associatedNonExplorerDocRefs =
                            importExportActionHandler.findAssociatedNonExplorerDocRefs(docRef);
                    if (associatedNonExplorerDocRefs != null) {
                        docRefs.addAll(associatedNonExplorerDocRefs);
                    }
                }
            }
        } catch (final RuntimeException e) {
            // We might get a permission exception which is expected for some users.
            LOGGER.debug(e.getMessage(), e);
        }
    }
Called recursively to add things to the set of Docs to export.
@param docRef The root docref
@param expandedDocRefs The output of the function
@param docTypesToIgnore Any types of doc to ignore and not recurse below.
stroom-importexport/stroom-importexport-impl/src/main/java/stroom/importexport/impl/ImportExportSerializerImpl.java