PsiElement[] (AbstractTreeNode<?>[] selected) { Set<PsiElement> result = new HashSet<>(); for(AbstractTreeNode<?> node: selected) { if (node.getValue() instanceof Form form) { result.add(form.getClassToBind()); ContainerUtil.addAll(result, form.getFormFiles()); } else if (node.getValue() instanceof PsiElement) { result.add((PsiElement) node.getValue()); } } return PsiUtilCore.toPsiElementArray(result); }