code: public static <T extends TreeNode<T>> T getRoot(T node) {
          if (node == null) return null;
          if (node.getParent() != null) return getRoot(node.getParent());
          return node;
      }
docs: Returns the root of the tree the given node is part of.
  
  @param node the node to get the root of
  @return the root or null if the given node is null