private static void validateChildren(SDDocumentType root, SDDocumentType currentDocument) {
        try {
            currentDocument.getDocumentReferences().get()
                    .forEach(entry -> {
                        SDDocumentType referencedDocument = entry.getValue().targetSearch().getDocument();
                        validateDocument(root, referencedDocument);
                    });
            currentDocument.getInheritedTypes()
                    .forEach(inheritedDocument -> {
                        if (!isRootDocument(inheritedDocument)) {
                            validateDocument(root, inheritedDocument);
                        }
                    });
        } catch (DocumentGraphException e) {
            e.addParentDocument(currentDocument);
            throw e;
        }
    }
Validates that there are no cycles between document types (exception: self-reference is allowed).
Example: if document B inherits A, then A cannot have a document reference to B.

@author bjorncs
config-model/src/main/java/com/yahoo/schema/DocumentGraphValidator.java