function forwardCurrentToHead(analyzer, node) {
  const codePath = analyzer.codePath;
  const state = CodePath.getState(codePath);
  const currentSegments = state.currentSegments;
  const headSegments = state.headSegments;
  const end = Math.max(currentSegments.length, headSegments.length);
  let i, currentSegment, headSegment;

  // Fires leaving events.
  for (i = 0; i < end; ++i) {
    currentSegment = currentSegments[i];
    headSegment = headSegments[i];

    if (currentSegment !== headSegment && currentSegment) {
      if (currentSegment.reachable) {
        analyzer.emitter.emit('onCodePathSegmentEnd', currentSegment, node);
      }
    }
  }

  // Update state.
  state.currentSegments = headSegments;

  // Fires entering events.
  for (i = 0; i < end; ++i) {
    currentSegment = currentSegments[i];
    headSegment = headSegments[i];

    if (currentSegment !== headSegment && headSegment) {
      CodePathSegment.markUsed(headSegment);
      if (headSegment.reachable) {
        analyzer.emitter.emit('onCodePathSegmentStart', headSegment, node);
      }
    }
  }
}
Updates the current segment with the head segment.
This is similar to local branches and tracking branches of git.

To separate the current and the head is in order to not make useless segments.

In this process, both "onCodePathSegmentStart" and "onCodePathSegmentEnd"
events are fired.
@param {CodePathAnalyzer} analyzer The instance.
@param {ASTNode} node The current AST node.
@returns {void}