code: private static TreeElement recursiveFindSelected(TreeElement elem)
      {
          assert(elem != null);
  
          if (elem.isSelected())
              return elem;
  
          TreeElement children[] = elem.getChildren();
          assert(children != null);
          for (int i = 0; i < children.length; i++) {
              TreeElement e = recursiveFindSelected(children[i]);
              if (e != null)
                  return e;
          }
          return null;
      }
docs: Recursive method that will find the currently selected element in the tree.
  @param elem The current element to search.
  @return a TreeElement that is selected.