if (node.getGID() == StoredNode.NODE_IMPL_ROOT_NODE_GID)
if (node.getGID() == StoredNode.NODE_IMPL_ROOT_NODE_GID) {
	private void copyNodes(Txn transaction, Iterator iterator, StoredNode node, NodePath currentPath, 	        DocumentImpl newDoc, boolean index) {		if (node.getNodeType() == Node.ELEMENT_NODE)		    currentPath.addComponent(node.getQName());		final DocumentImpl doc = (DocumentImpl)node.getOwnerDocument();		node.setOwnerDocument(newDoc);		node.setInternalAddress(BFile.UNKNOWN_ADDRESS);		store(transaction, node, currentPath, index);		if (node.getNodeType() == Node.ELEMENT_NODE)		    endElement(node, currentPath, null);				if (node.getGID() == StoredNode.NODE_IMPL_ROOT_NODE_GID)		    newDoc.appendChild((StoredNode) node);		node.setOwnerDocument(doc);				if (node.hasChildNodes()) {			final long firstChildId = XMLUtil.getFirstChildId(doc, node.getGID());            			if (firstChildId < 0) {				LOG.fatal(					"no child found: expected = "						+ node.getChildCount()						+ "; node = "						+ node.getNodeName()						+ "; gid = "						+ node.getGID());				throw new IllegalStateException("wrong node id");			}			final long lastChildId = firstChildId + node.getChildCount();			StoredNode child;			for (long gid = firstChildId; gid < lastChildId; gid++) {				child = (StoredNode) iterator.next();				if(child == null)					LOG.debug("child " + gid + " not found for node: " + node.getNodeName() +							"; last = " + lastChildId + "; children = " + node.getChildCount());				child.setGID(gid);				copyNodes(transaction, iterator, child, currentPath, newDoc, index);			}		}		if(node.getNodeType() == Node.ELEMENT_NODE) {		    currentPath.removeLastComponent();		}	}