throw new DomEx(DomEx.HIERARCHY_REQUEST_ERR, "can't insert node before itself", ref, 0);
throw new DomDOMException(DOMException.HIERARCHY_REQUEST_ERR, "can't insert node before itself", ref, 0);
  public Node insertBefore(Node newChild, Node refChild)  {    if (refChild == null)      {        return appendChild(newChild);      }    try      {        DomNode	child = (DomNode) newChild;        DomNode ref = (DomNode) refChild;                if (child.nodeType == DOCUMENT_FRAGMENT_NODE)          {            // Append all nodes in the fragment to this node            for (DomNode ctx = child.first; ctx != null; ctx = ctx.next)              {                checkMisc(ctx);              }            for (DomNode ctx = child.first; ctx != null; )              {                DomNode ctxNext = ctx.next;                insertBefore(ctx, ref);                ctx = ctxNext;              }          }        else          {            checkMisc(child);            if (ref == null || ref.parent != this)              {                throw new DomEx(DomEx.NOT_FOUND_ERR, null, ref, 0);              }            if (ref == child)              {                throw new DomEx(DomEx.HIERARCHY_REQUEST_ERR,                                "can't insert node before itself", ref, 0);              }                    if (child.parent != null)              {                child.parent.removeChild(child);              }            child.parent = this;            int i = ref.index;            child.setDepth(depth + 1);            child.next = ref;            if (ref.previous != null)              {                ref.previous.next = child;              }            child.previous = ref.previous;            ref.previous = child;            if (first == ref)              {                first = child;              }            // index renumbering            for (DomNode ctx = child; ctx != null; ctx = ctx.next)              {                ctx.index = i++;              }            if (reportMutations)              {                insertionEvent(null, child);              }          }                return child;      }    catch (ClassCastException e)      {        throw new DomEx(DomEx.WRONG_DOCUMENT_ERR,                        null, newChild, 0);      }  }