private NodeRef findOrCreateTree(final String treePath, final FeatureType type) { RevTree tree = context .command(FindOrCreateSubtree.class) .setChildPath(treePath) .setIndex(true) .setParent(workHead) .setParentPath(NodeRef.ROOT) .call(); ObjectId metadataId = ObjectId.NULL; if (type != null) { RevFeatureType revFeatureType = RevFeatureTypeImpl.build(type); if (tree.isEmpty()) { indexDatabase.put(revFeatureType); } metadataId = revFeatureType.getId(); } Envelope bounds = SpatialOps.boundsOf(tree); Node node = Node.create(NodeRef.nodeFromPath(treePath), tree.getId(), metadataId, TYPE.TREE, bounds); String parentPath = NodeRef.parentPath(treePath); return new NodeRef(node, parentPath, ObjectId.NULL); }