private static <T> int trailingNullsIndex(T @NotNull [] array) {
    for (int i = array.length - 1; i >= 0; i--) {
      if (array[i] != null) {
        return i + 1;
      }
    }
    return 0;
  }
private static <T> int trailingNullsIndex(T @NotNull [] array)