function addToReturnedOrThrown(dest, others, all, segments) {
  for (let i = 0; i < segments.length; ++i) {
    const segment = segments[i];

    dest.push(segment);
    if (!others.includes(segment)) {
      all.push(segment);
    }
  }
}
Adds given segments into the `dest` array.
If the `others` array does not includes the given segments, adds to the `all`
array as well.

This adds only reachable and used segments.
@param {CodePathSegment[]} dest A destination array (`returnedSegments` or `thrownSegments`).
@param {CodePathSegment[]} others Another destination array (`returnedSegments` or `thrownSegments`).
@param {CodePathSegment[]} all The unified destination array (`finalSegments`).
@param {CodePathSegment[]} segments Segments to add.
@returns {void}