def wrap(node, tag):
wrap_node = node.ownerDocument.createElement(tag)<EOL>parent = node.parentNode<EOL>if parent:<EOL><INDENT>parent.replaceChild(wrap_node, node)<EOL><DEDENT>wrap_node.appendChild(node)<EOL>return wrap_node<EOL>
Wrap the given tag around a node.