code: function restore($old, $new) {
          // We append the next element after this point. If $after is not yet set, we prepend to $new
          // and then set $after to the node just prepended.
          var $after;
          $new.contents().each(function() {
            var $node = $(this);
            var handled = false;
            var $nodeOld;
            if (is($node, 'preserve')) {
              $nodeOld = findVal($old, 'preserve', attr($node, 'preserve'));
              $after = $nodeOld;
              handled = true;
            } else if (is($node, 'preserves')) {
              $nodeOld = findVal($old, 'preserves', attr($node, 'preserves'));
              if ($nodeOld.length) {
                restore($nodeOld, $node);
                $after = $nodeOld;
                handled = true;
              }
            }
            if (!handled) {
              if ($after) {
                $after.after($node);
              } else {
                $old.prepend($node);
              }
              $after = $node;
            }
          });
        }
docs: Copy children of $new to $old except where a preserved element or its ancestor must be respected; flow the new elements around those, after invoking recursively where appropriate