code: @Nullable
    public static Document getOwnerDocument (@Nullable final Node aNode)
    {
      if (aNode == null)
        return null;
      if (aNode instanceof Document)
        return (Document) aNode;
      return aNode.getOwnerDocument ();
    }
docs: Get the owner document of the passed node. If the node itself is a
  document, only a cast is performed.
  
  @param aNode
  The node to get the document from. May be <code>null</code>.
  @return <code>null</code> if the passed node was <code>null</code>.