void (@NotNull AbstractTreeBuilder treeBuilder, @NotNull List<Object> pathsToExpand, @NotNull List<Object> selectionPaths, boolean elementsOnly) { JTree tree = treeBuilder.getTree(); if (!elementsOnly){ for (Object path : pathsToExpand) { tree.expandPath((TreePath)path); } tree.addSelectionPaths(selectionPaths.toArray(TreeUtil.EMPTY_TREE_PATH)); } else{ for (Object element : pathsToExpand) { treeBuilder.buildNodeForElement(element); DefaultMutableTreeNode node = treeBuilder.getNodeForElement(element); if (node != null) { tree.expandPath(new TreePath(node.getPath())); } } for (Object element : selectionPaths) { DefaultMutableTreeNode node = treeBuilder.getNodeForElement(element); if (node != null) { DefaultTreeModel treeModel = (DefaultTreeModel)tree.getModel(); tree.addSelectionPath(new TreePath(treeModel.getPathToRoot(node))); } } } }