result = appendChild(first, this, getPath(), newChild, false);
result = appendChild(first, new NodeImplRef(this), getPath(), newChild, false);
    public Node insertBefore(Node newChild, Node refChild)            throws DOMException {        if (!(refChild instanceof NodeImpl))            throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, "wrong node type");        DocumentImpl prevDoc = new DocumentImpl(ownerDocument);        if (refChild == null)            return appendChild(newChild);        NodeImpl ref = (NodeImpl) refChild;        long first = firstChildID();        if (ref.gid < first || ref.gid > ref.gid + children - 1)            throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR,                    "reference node is not a child of the selected node");        Node result;        if (ref.gid == first)            result = appendChild(first, this, getPath(), newChild, false);        else {            NodeImpl prev = (NodeImpl) ref.getPreviousSibling();            result = appendChild(ref.gid, getLastNode(prev), getPath(), newChild, false);        }        ownerDocument.broker.update(this);        ownerDocument.broker.reindex(prevDoc, ownerDocument, null);        try {            ownerDocument.broker.saveCollection(ownerDocument.getCollection());        }        catch (PermissionDeniedException e) {        }        return result;    }