void (@NotNull RefEntity elem) { if (elem instanceof RefElement refElement) { entitiesWithParents.put(refElement, refElement.getInReferences()); if (refElement.getInReferences().isEmpty() || refElement.getInReferences().contains(refElement)) { roots.add(refElement); } } }