Tree implements Serializable { public void addSubtrees(Iterable<Tree<T>> subtrees, Iterable<T> edgeLabels) { Iterator<Tree<T>> treeIter = subtrees.iterator(); Iterator<T> edgeIter = edgeLabels.iterator(); while (treeIter.hasNext() && edgeIter.hasNext()) { this.addSubtree(treeIter.next(), edgeIter.next()); } } Tree();  Tree(T label); void addSubtreeAt(Tree<T> tree, T edgeLabel, int position); void addSubtreeAt(Tree<T> tree, int position); void addSubtree(Tree<T> tree, T edgeLabel); void addSubtree(Tree<T> tree); void addSubtrees(Iterable<Tree<T>> subtrees, Iterable<T> edgeLabels); void addSubtrees(Iterable<Tree<T>> subtrees); void addLeaf(T leafLabel, T edgeLabel); void addLeaf(T leafLabel); static Tree<String> readTreeFromString(String treeString); Tree<T> getChild(int position); T getLabel(); Iterable<Tree<T>> childrenIterator(); Iterable<T> childrenEdgeLabelIterator(); List<Tree<T>> getChildren(); List<T> getChildrenEdgeLabels(); T getEdgeLabel(int childId); int size(); List<Tree<T>> getYield(); boolean isLeaf(); int getNumberOfChildren(); Tree<T> getParent(); boolean isRoot(); int getHeight(); int getPositionAmongParentsChildren(); @Override String toString(); @SuppressWarnings("unchecked") @Override Object clone(); @SuppressWarnings("unchecked") @Override boolean equals(Object obj); @Override int hashCode(); void removeChildAt(int position); boolean hasEdgeLabels();  }
@Test public final void testAddSubtrees() { Tree<String> tree2 = new Tree<>("Root"); tree2.addLeaf("Leaf"); Tree<String> treeChild1 = new Tree<>("Child1"); treeChild1.addLeaf("Child1Leaf"); Tree<String> treeLeaf2 = new Tree<>("Leaf"); Tree<String> treeChild2 = new Tree<>("Child2"); treeChild2.addLeaf("Child2Leaf1"); treeChild2.addLeaf("Child2Leaf2"); ArrayList<Tree<String>> subtrees = new ArrayList<>(); subtrees.add(treeChild1); subtrees.add(treeChild2); subtrees.add(treeLeaf2); tree2.addSubtrees(subtrees); assertEquals(tree2.toString(), tree.toString()); assertEquals(tree2.equals(tree), true); }