function cloneDOM(root) {
        var nodeMap = {};

        // If there's no DOM to clone, then we must be starting from an empty document,
        // so start with a document that already has implied <html>/<head>/<body>, since
        // that's what the browser does.
        if (!root) {
            root = createBlankDOM();
        }

        function doClone(parent, node) {
            var newNode = Object.create(domFeatures);
            newNode.parent = parent;
            if (node.tagID) {
                nodeMap[node.tagID] = newNode;
                newNode.tagID = node.tagID;
            }
            newNode.content = node.content;
            if (node.children) {
                newNode.tag = node.tag;
                newNode.attributes = $.extend({}, node.attributes);
                newNode.children = node.children.map(function (child) {
                    return doClone(newNode, child);
                });
            } else {
                newNode.content = node.content;
            }
            return newNode;
        }

        var newRoot = doClone(null, root);
        newRoot.nodeMap = nodeMap;
        return newRoot;
    }
Creates a deep clone of a SimpleDOM tree, adding the domFeatures as it goes
along.

@param {Object} root root node of the SimpleDOM to clone
@return {Object} cloned SimpleDOM with domFeatures applied