code: function maybeImportNode(state, node, doc) {
    return node.ownerDocument === doc ? node : doc.importNode(node, true);
  }
docs: Return node or a import of node, if it's not in the given document
  @param node The node that we want to be properly owned
  @param doc The document that the given node should belong to
  @return A node that belongs to the given document