package dir; import java.util.ArrayList; import java.util.List; public class Tree { private T node; private List> children; public Tree(T data){ this.node = data; this.children = new ArrayList>(); } public void addChild(T child) { Tree childNode = new Tree(child); this.children.add(childNode); } public void appendChildrenList(List childList) { for(int i=0;i childNode = new Tree(childList.get(i)); this.children.add(childNode); } } public T getNode(){ return this.node; } public List> getChildrenList(){ return this.children; } }