List<DefaultMutableTreeNode> (@NotNull List<Integer> rows) { List<DefaultMutableTreeNode> nodes = new ArrayList<>(); for (Integer row : rows) { TreePath path = myTree.getPathForRow(row); Object pathComponent = path == null ? null : path.getLastPathComponent(); if (pathComponent instanceof DefaultMutableTreeNode) { nodes.add((DefaultMutableTreeNode)pathComponent); } } return nodes; }