static flattenPayload_(cue, parentCue) {
    if (cue.lineBreak) {
      // This is a vertical lineBreak, so insert a newline.
      return '\n';
    }
    if (cue.nestedCues.length) {
      return cue.nestedCues.map((nested) => {
        return shaka.text.Utils.flattenPayload_(nested, cue);
      }).join('');
    }

    if (!cue.payload) {
      return cue.payload;
    }

    // Handle bold, italics and underline
    const openStyleTags = [];
    const bold = cue.fontWeight >= shaka.text.Cue.fontWeight.BOLD;
    const italics = cue.fontStyle == shaka.text.Cue.fontStyle.ITALIC;
    const underline = cue.textDecoration.includes(
        shaka.text.Cue.textDecoration.UNDERLINE);
    if (bold) {
      openStyleTags.push(['b']);
    }
    if (italics) {
      openStyleTags.push(['i']);
    }
    if (underline) {
      openStyleTags.push(['u']);
    }
    // Handle color classes, if the value consists of letters
    let color = cue.color;
    if (color == '' && parentCue) {
      color = parentCue.color;
    }
    let classes = '';
    const colorName = shaka.text.Utils.getColorName_(color);
    if (colorName) {
      classes += `.${colorName}`;
    }
    let bgColor = cue.backgroundColor;
    if (bgColor == '' && parentCue) {
      bgColor = parentCue.backgroundColor;
    }
    const bgColorName = shaka.text.Utils.getColorName_(bgColor);
    if (bgColorName) {
      classes += `.bg_${bgColorName}`;
    }
    if (classes) {
      openStyleTags.push(['c', classes]);
    }

    return openStyleTags.reduceRight((acc, [tag, classes = '']) => {
      return `<${tag}${classes}>${acc}</${tag}>`;
    }, cue.payload);
  }
Flatten nested cue payloads recursively.  If a cue has nested cues,
their contents should be combined and replace the payload of the parent.

@param {!shaka.text.Cue} cue
@param {?shaka.text.Cue=} parentCue
@return {string}
@private