DefaultMutableTreeNode (@NotNull JTree tree, boolean forward) { TreePath selectionPath = tree.getSelectionPath(); TreeNode selectedNode = null; if (selectionPath != null) { selectedNode = (TreeNode)selectionPath.getLastPathComponent(); } return findNextNodeAfter(tree, selectedNode, forward); }