private static AnsiTerminalColor decodeColor(@NotNull Iterator<Integer> encodedColorIterator) {
    if (!encodedColorIterator.hasNext()) {
      return null;
    }
    int encodingType = encodedColorIterator.next();
    if (encodingType == SGR_COLOR_ENCODING_RGB) {
      Integer redCode = encodedColorIterator.hasNext() ? encodedColorIterator.next() : null;
      Integer greenCode = encodedColorIterator.hasNext() ? encodedColorIterator.next() : null;
      Integer blueCode = encodedColorIterator.hasNext() ? encodedColorIterator.next() : null;
      if (redCode != null && greenCode != null && blueCode != null) {
        return new RGBColor(redCode, greenCode, blueCode);
      }
    }
    else if (encodingType == SGR_COLOR_ENCODING_INDEXED) {
      Integer encodedColor = encodedColorIterator.hasNext() ? encodedColorIterator.next() : null;
      if (encodedColor != null) {
        return decode8BitColor(encodedColor);
      }
    }

    return null;
  }
private static AnsiTerminalColor decodeColor(@NotNull Iterator<Integer> encodedColorIterator)