private static boolean isImmutable(final @NotNull CharSequence cs) {
    return cs instanceof ImmutableCharSequence ||
           cs instanceof CharSequenceSubSequence && isImmutable(((CharSequenceSubSequence)cs).getBaseSequence());
  }
private static boolean isImmutable(final @NotNull CharSequence cs)