import java.util.ArrayList; import java.util.List; public class Node { private T value; private List> subNodes; public Node(T value) { this.value = value; this.subNodes = new ArrayList<>(); } public T getValue() { return value; } public void setValue(T value) { this.value = value; } public List> getSubNodes() { return this.subNodes; } public boolean addSubNode(Node node) { return subNodes.add(node); } public boolean remSubNode(Node node) { return subNodes.remove(node); } public void showNode() { System.out.print(value.toString() + " "); for (Node subNode : subNodes) { subNode.showNode(); } } }