static <L> Tree<L> stripLeaves(Tree<L> tree) {
      if (tree.isLeaf())
        return null;
      if (tree.isPreTerminal())
        return new Tree<L>(tree.getLabel());
      List<Tree<L>> children = new ArrayList<Tree<L>>();
      for (Tree<L> child : tree.getChildren()) {
        children.add(stripLeaves(child));
      }
      return new Tree<L>(tree.getLabel(), children);
    }