code: public int getDocumentRoot(int nodeHandle)
    {
      for (int id=makeNodeIdentity(nodeHandle); id!=NULL; id=_parent(id)) {
        if (_type(id)==DTM.DOCUMENT_NODE) {
          return makeNodeHandle(id);
        }
      }
  
      return DTM.NULL; // Safety net; should never happen
    }
docs: Given a node handle, find the owning document node, using DTM semantics
  (Document owns itself) rather than DOM semantics (Document has no owner).
  
  (I'm counting on the fact that getOwnerDocument() is implemented on top
  of this call, in the superclass, to avoid having to rewrite that one.
  Be careful if that code changes!)
  
  @param nodeHandle the id of the node.
  @return int Node handle of owning document