function mergeExtraSegments(context, segments) {
	let currentSegments = segments;

	/*
	 * We need to ensure that the array returned from this function contains no more
	 * than the number of segments that the context allows. `context.count` indicates
	 * how many items should be in the returned array to ensure that the new segment
	 * entries will line up with the already existing segment entries.
	 */
	while (currentSegments.length > context.count) {
		const merged = [];

		/*
		 * Because `context.count` is a factor of 2 inside of a `finally` block,
		 * we can divide the segment count by 2 to merge the paths together.
		 * This loops through each segment in the list and creates a new `CodePathSegment`
		 * that has the segment and the segment two slots away as previous segments.
		 *
		 * If `currentSegments` is [a,b,c,d], this will create new segments e and f, such
		 * that:
		 *
		 * When `i` is 0:
		 * a->e
		 * c->e
		 *
		 * When `i` is 1:
		 * b->f
		 * d->f
		 */
		for (
			let i = 0, length = Math.floor(currentSegments.length / 2);
			i < length;
			++i
		) {
			merged.push(
				CodePathSegment.newNext(context.idGenerator.next(), [
					currentSegments[i],
					currentSegments[i + length],
				]),
			);
		}

		/*
		 * Go through the loop condition one more time to see if we have the
		 * number of segments for the context. If not, we'll keep merging paths
		 * of the merged segments until we get there.
		 */
		currentSegments = merged;
	}

	return currentSegments;
}
Inside of a `finally` block we end up with two parallel paths. If the code path
exits by a control statement (such as `break` or `continue`) from the `finally`
block, then we need to merge the remaining parallel paths back into one.
@param {ForkContext} context The fork context to work on.
@param {Array<CodePathSegment>} segments Segments to merge.
@returns {Array<CodePathSegment>} The merged segments.