code: public static TreeElement changeSelected(TreeElement root, TreeElement selectedNode, String selectNode, ServletRequest request)
      {
          assert(root != null) : "parameter 'root' must not be null";
          assert(selectNode != null) : "parameter 'selectNode' must not be null";
          assert(request != null) : "parameter 'request' must not be null";
  
          // if there is a selectedNode then we need to raise the onSelect
          // event on that node indicating it will soon not be selected
          TreeElement n = root.findNode(selectNode);
          if (n == null) {
              logger.warn("The tree element '" + selectNode + "' was not found.  Selection failed");
              return null;
          }
  
          // change the node that was selected so it is no longer selected
          if (selectedNode != null) {
              selectedNode.onSelect(request);
              selectedNode.setSelected(false);
          }
  
          // change the node that is to be selected
          n.onSelect(request);
          n.setSelected(true);
          return n;
      }
docs: This is a helper method that will change the selected node.  This is provided to
  make implementation of ITreeRootElement easier.  This is called by the <code>changeSelected</code>
  method there to do the work of changing the selected node.
  @param root         The root of the tree
  @param selectedNode The node that is currently selected, it may be null
  @param selectNode   The String name of the node that will be selected
  @param request      The ServletRequest
  @return a TreeElement representing the new node selected.