static flattenUnusedSegments(segments) {
		const done = new Set();

		for (let i = 0; i < segments.length; ++i) {
			const segment = segments[i];

			// Ignores duplicated.
			if (done.has(segment)) {
				continue;
			}

			// Use previous segments if unused.
			if (!segment.internal.used) {
				for (let j = 0; j < segment.allPrevSegments.length; ++j) {
					const prevSegment = segment.allPrevSegments[j];

					if (!done.has(prevSegment)) {
						done.add(prevSegment);
					}
				}
			} else {
				done.add(segment);
			}
		}

		return [...done];
	}
Creates a new array based on an array of segments. If any segment in the
array is unused, then it is replaced by all of its previous segments.
All used segments are returned as-is without replacement.
@param {CodePathSegment[]} segments The array of segments to flatten.
@returns {CodePathSegment[]} The flattened array.