void (@NotNull RefElement refElement, @NotNull List<? super RefElement> deletedRefs) { refElement.initializeIfNeeded(); List<RefEntity> children = refElement.getChildren(); RefElement[] refElements = children.toArray(new RefElement[0]); for (RefElement refChild : refElements) { removeRefElement(refChild, deletedRefs); } ((RefManagerImpl)refElement.getRefManager()).removeReference(refElement); ((RefElementImpl)refElement).referenceRemoved(); if (!deletedRefs.contains(refElement)) { deletedRefs.add(refElement); } else { LOG.error("deleted second time"); } }