code: function traverseStacks(prev, next, time) {
      // A list of enter events to execute in reverse order after all necessary
      // exit events have been emitted.
      var enters = [];
      // Terminate any excess scopes from prev.
      while (prev['depth'] > next['depth']) {
        eventList.insert(leaveEventType, time);
        prev = prev['parent'];
      }
      // Enter any new level of scope from next.
      while (next['depth'] > prev['depth']) {
        enters.push(next['callUID']);
        next = next['parent'];
      }
      // At this point the stacks are the same depth and we need to traverse up
      // to where they join (which may be the root).
      while (prev != next) {
        eventList.insert(leaveEventType, time);
        enters.push(next['callUID']);
        prev = prev['parent'];
        next = next['parent'];
      }
      // Now add all the scope enter events in reverse order.
      for (var i = enters.length - 1; i >= 0; i--) {
        eventList.insert(eventTypesByCallUID[enters[i]], time);
      }
    }
docs: This function takes a pair of profiler samples and infers a nested call stack relationship. For example, a,b,c and d,b,c would be interpreted as a single call to c, which makes a single call to b, which makes two calls: one to a, and one to d. This may be wrong (c may have made TWO calls to b), but it's the best we can do with sample information.