void (final TreeElement parent, final Collection<? super PsiElement> array, @NotNull PsiFile file) { for(TreeElement treeElement: parent.getChildren()) { Object value = ((StructureViewTreeElement)treeElement).getValue(); if (value instanceof PsiElement element) { if (array.contains(element) || !file.equals(element.getContainingFile())) continue; array.add(element); } addStructureViewElements(treeElement, array, file); } }