static getCuesToFlatten(cues, parentCue) {
    const result = [];
    for (const cue of shaka.text.Utils.removeDuplicates(cues)) {
      if (cue.isContainer) {
        // Recurse to find the actual text payload cues.
        result.push(...shaka.text.Utils.getCuesToFlatten(cue.nestedCues, cue));
      } else {
        // Flatten the payload.
        const flatCue = cue.clone();
        flatCue.nestedCues = [];
        flatCue.payload = shaka.text.Utils.flattenPayload_(cue, parentCue);
        result.push(flatCue);
      }
    }
    return result;
  }
We don't want to modify the array or objects passed in, since we don't
technically own them.  So we build a new array and replace certain items
in it if they need to be flattened.
We also don't want to flatten the text payloads starting at a container
element; otherwise, for containers encapsulating multiple caption lines,
the lines would merge into a single cue. This is undesirable when a
subset of the captions are outside of the append time window. To fix
this, we only call flattenPayload() starting at elements marked as
isContainer = false.

@param {!Array<!shaka.text.Cue>} cues
@param {?shaka.text.Cue=} parentCue
@return {!Array<!shaka.text.Cue>}