}
	private void copyNodes(Iterator iterator, NodeImpl 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(-1);		store(node, currentPath, index);		if(node.getGID() == 1)		    newDoc.appendChild(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();			NodeImpl child;			for (long gid = firstChildId; gid < lastChildId; gid++) {				child = (NodeImpl) iterator.next();				if(child == null)					LOG.debug("child " + gid + " not found for node: " + node.getNodeName() +							"; last = " + lastChildId + "; children = " + node.getChildCount());				child.setGID(gid);				copyNodes(iterator, child, currentPath, newDoc, index);			}		}		if(node.getNodeType() == Node.ELEMENT_NODE)		    currentPath.removeLastComponent();	}