TreeModel implements Serializable { public void addNode(NodeModel<T> start, NodeModel<T>... nodes) { int index = 1; NodeModel<T> temp = start; if (temp.getParentNode() != null) { index = temp.getParentNode().floor; } LinkedList<NodeModel<T>> childNodes = temp.getChildNodes(); for (NodeModel<T> t : nodes) { t.setParentNode(start); t.setFloor(index); boolean exist = false; for (NodeModel<T> hash : childNodes) { if (hash == t) { exist = true; continue; } } if (!exist) start.getChildNodes().add(t); } } TreeModel(NodeModel<T> rootNode); void addNode(NodeModel<T> start, NodeModel<T>... nodes); boolean removeNode(NodeModel<T> starNode, NodeModel<T> deleteNote); boolean inTree(NodeModel<T> starNode, NodeModel<T> deleteNote); NodeModel<T> getRootNode(); void setRootNode(NodeModel<T> rootNode); ArrayList<NodeModel<T>> getAllLowNodes(NodeModel<T> addNode); ArrayList<NodeModel<T>> getAllPreNodes(NodeModel<T> addNode); LinkedList<NodeModel<T>> getNodeChildNodes(NodeModel<T> node); void ergodicTreeInDeep(int msg); void ergodicTreeInWith(int msg); void addForTreeItem(ForTreeItem<NodeModel<T>> forTreeItem); Object deepClone();  }
@Test public void addNode() throws Exception { NodeModel<String> addNode = new NodeModel<>("add note"); mTreeModel.addNode(mTreeModel.getRootNode(), addNode); mTreeModel.addForTreeItem(new ForTreeItem<NodeModel<String>>() { @Override public void next(int msg, NodeModel<String> next) { System.out.printf("%s>>", next.getValue()); } }); mTreeModel.ergodicTreeInWith(1); }