code: function flattenUnusedSegments(segments) {
  		var done = Object.create(null);
  		var retv = [];
  
  		for (var i = 0; i < segments.length; ++i) {
  			var segment = segments[i];
  
  			// Ignores duplicated.
  			if (done[segment.id]) {
  				continue;
  			}
  
  			// Use previous segments if unused.
  			if (!segment.internal.used) {
  				for (var j = 0; j < segment.allPrevSegments.length; ++j) {
  					var prevSegment = segment.allPrevSegments[j];
  
  					if (!done[prevSegment.id]) {
  						done[prevSegment.id] = true;
  						retv.push(prevSegment);
  					}
  				}
  			} else {
  				done[segment.id] = true;
  				retv.push(segment);
  			}
  		}
  
  		return retv;
  	}
docs: ------------------------------------------------------------------------------ Helpers ------------------------------------------------------------------------------ 
  Replaces unused segments with the previous segments of each unused segment.
  
  @param {CodePathSegment[]} segments - An array of segments to replace.
  @returns {CodePathSegment[]} The replaced array.