List<String> () { List<String> tasks = new ArrayList<>(); for (DefaultMutableTreeNode node : myTree.getSelectedNodes(DefaultMutableTreeNode.class, null)) { if (node.getUserObject() instanceof ProjectNode projectNode) { tasks.add(projectNode.myProjectPath); } } return tasks; }