public DefaultMutableTreeNode findNextNodeAfter(@NotNull JTree tree, TreeNode selectedNode, boolean forward) {
    if (selectedNode == null) {
      selectedNode = (TreeNode)tree.getModel().getRoot();
    }
    if (selectedNode == null) {
      return null;
    }
    if (forward) {
      for (DefaultMutableTreeNode node=((DefaultMutableTreeNode)selectedNode).getNextNode(); node != null; node = node.getNextNode()) {
        if (createDescriptorForNode(node) != null) {
          return node;
        }
      }
    }
    else {
      for (DefaultMutableTreeNode node=((DefaultMutableTreeNode)selectedNode).getPreviousNode(); node != null; node = node.getPreviousNode()) {
        if (createDescriptorForNode(node) != null) {
          return node;
        }
      }
    }

    return null;
  }
public DefaultMutableTreeNode findNextNodeAfter(@NotNull JTree tree, TreeNode selectedNode, boolean forward)