### Question:
MutableTree implements Cloneable { public RevTree build(ObjectDatabase origin, ObjectDatabase target) { final ObjectId nodeId = node.getObjectId(); final RevTree tree = origin.getTree(nodeId); RevTreeBuilder builder = tree.builder(target).clearSubtrees(); for (MutableTree childTree : this.childTrees.values()) { String name; ObjectId newObjectId; ObjectId metadataId; Envelope bounds; { RevTree newChild = childTree.build(origin, target); target.put(newChild); Node oldNode = childTree.getNode(); name = oldNode.getName(); newObjectId = newChild.getId(); metadataId = oldNode.getMetadataId().or(ObjectId.NULL); bounds = SpatialOps.boundsOf(newChild); } Node newNode = Node.create(name, newObjectId, metadataId, TYPE.TREE, bounds); builder.put(newNode); } RevTree newTree = builder.build(); if (!this.node.getObjectId().equals(newTree.getId())) { target.put(newTree); Envelope bounds = SpatialOps.boundsOf(newTree); this.node = Node.create(node.getName(), newTree.getId(), node.getMetadataId().or(ObjectId.NULL), TYPE.TREE, bounds); } return newTree; } private  MutableTree(String name); private  MutableTree(Node node); @Override String toString(); @Override boolean equals(Object o); static MutableTree createFromRefs(final ObjectId rootId,
            final Supplier<Iterator<NodeRef>> refs); static MutableTree createFromRefs(final ObjectId rootId,
            @Nullable final NodeRef... treeRefs); static MutableTree createFromRefs(final ObjectId rootId, final Iterator<NodeRef> treeRefs); static MutableTree createFromPaths(final ObjectId rootId,
            final Map<String, NodeRef> entries); Node getNode(); void forceChild(final String parentPath, final Node treeNode); void setChild(String parentPath, Node node); void setChild(final List<String> parentPath, final Node node); MutableTree getChild(String path); MutableTree getChild(final List<String> path); SortedMap<String, MutableTree> getChildrenAsMap(); @Nullable MutableTree removeChild(String path); void setNode(final Node newNode); RevTree build(ObjectDatabase origin, ObjectDatabase target); @Override MutableTree clone(); static final Ordering<NodeRef> DEEPEST_LAST_COMPARATOR; static final Ordering<NodeRef> DEEPEST_FIRST_COMPARATOR; }### Answer:
@Test @Ignore public void testBuild() { ObjectDatabase origin = new HeapObjectDatabse(); origin.open(); ObjectDatabase target = new HeapObjectDatabse(); target.open(); RevTree tree = root.build(origin, target); Iterator<NodeRef> treeRefs = new DepthTreeIterator("", ObjectId.NULL, tree, target, Strategy.RECURSIVE_TREES_ONLY); MutableTree createFromRefs = MutableTree.createFromRefs(root.getNode().getObjectId(), treeRefs); }