lastNode = getLastNode((NodeImpl) ownerDocument.getNode(childGid - 1));
last.node = getLastNode((NodeImpl) ownerDocument.getNode(childGid - 1));
    public Node appendChild(Node child)            throws DOMException {        DocumentImpl prevDoc = new DocumentImpl(ownerDocument);        long childGid;        NodeImpl lastNode;        if (children == 0) {            childGid = firstChildID();            lastNode = this;        }        else {            childGid = lastChildID() + 1;            lastNode = getLastNode((NodeImpl) ownerDocument.getNode(childGid - 1));        }        try {            checkTree(1);        }        catch (EXistException e) {            throw new DOMException(DOMException.INVALID_MODIFICATION_ERR,                    "max. document size exceeded");        }        children++;        Node node = appendChild(childGid, lastNode, getPath(), child, true);        ownerDocument.broker.update(this);        ownerDocument.broker.reindex(prevDoc, ownerDocument, null);        try {            ownerDocument.broker.saveCollection(ownerDocument.getCollection());        }        catch (PermissionDeniedException e) {            throw new DOMException(DOMException.INVALID_ACCESS_ERR, e.getMessage());        }        return child;    }