List<PsiAnonymousClass> () { JBTreeTraverser<AbstractTreeNode<?>> traverser = JBTreeTraverser.from(AbstractTreeNode::getChildren); List<AbstractTreeNode<?>> roots = new ArrayList<>(); for (Object element : getElements()) { if (element instanceof AbstractTreeNode) { roots.add((AbstractTreeNode<?>)element); } } return traverser.withRoots(roots) .traverse() .map(StructureViewComponent::unwrapValue) .filter(PsiAnonymousClass.class) .toList(); }