boolean (final Processor<? super Library> processor) { DefaultMutableTreeNode[] nodes = myTree.getSelectedNodes(DefaultMutableTreeNode.class, null); for (Object element : ContainerUtil.map(nodes, node -> ((NodeDescriptor<?>)node.getUserObject()).getElement())) { if (element instanceof Library) { if (!processor.process((Library)element)) return false; } } return true; }