code: public static Document getOwnerDocument(Node n) {
      return n == null || !isElement(n) ? null : n.getNodeType() == Node.DOCUMENT_NODE
          ? n.<Document> cast() : n.getOwnerDocument();
    }
docs: Returns the owner document element of an element.