code: function mutateDOM(contexts) {
      var length = contexts.length;
      var index, context, parent, childrenLength, oldOrder, newOrder;
      var moves, movesLength, move, beforeElement;
      var moving = {};
  
      for (index = 0; index < length; index++) {
          context = contexts[index];
          parent = context.parent;
          childrenLength = context.children.length;
  
          oldOrder = parent.children;
          newOrder = new Array(childrenLength);
          while (childrenLength--) {
              newOrder[childrenLength] = context.children[childrenLength].node;
          }
  
          moves = diff(oldOrder, newOrder);
  
          movesLength = moves.length;
          while (movesLength--) {
              moving[getID(moves[movesLength].element)] = moves[movesLength].index;
          }
  
          movesLength = moves.length;
          while (movesLength--) {
              move = moves[movesLength];
              beforeElement = newOrder[move.index + 1] || null;
  
              while (true) {
                  if (beforeElement && (moving[getID(beforeElement)] !== undefined)) {
                      // The element we're inserting this one before is going to be moved—but has not
                      // been moved yet, take its place.
                      beforeElement = newOrder[moving[getID(beforeElement)] + 1];
                  } else {
                      break;
                  }
              }
  
              moving[getID(move.element)] = undefined;
              parent.insertBefore(move.element, beforeElement);
          }
      }
  }
docs: This Function loops through contexts and applies the nesting/ordering logic there to the DOM.