static removeCuesFromTextTrack(texTrack, predicate) {
    // Since |track.cues| can be null if |track.mode| is "disabled", force it
    // to something other than "disabled".
    //
    // If the texTrack is already showing, then we should keep it as showing.
    // But if it something else, we will use hidden so that we don't "flash"
    // cues on the screen.
    let disabled = false;

    if (texTrack.mode === 'disabled') {
      disabled = true;
      texTrack.mode = 'hidden';
      goog.asserts.assert(
          texTrack.cues,
          'Cues should be accessible when mode is set to "hidden".',
      );
    }

    let i = 0;
    while (i < texTrack.cues.length) {
      const cue = texTrack.cues[i];
      if (predicate(cue)) {
        texTrack.removeCue(cue);
      } else {
        i++;
      }
    }

    if (disabled) {
      texTrack.mode = 'disabled';
    }
  }
Iterate over all the cues in a text track and remove all those for which
|predicate(cue)| returns true.

@param {!TextTrack} texTrack
@param {function(!TextTrackCue):boolean} predicate