code: private static void adjustGroupIndices(int[][] allGroupIndices,
              int modifiedIndex, boolean remove) {
          final int offset = remove ? -1 : +1;
          for (int[] allGroupIndice : allGroupIndices) {
              int[] groupIndices = allGroupIndice;
              for (int i = 0; i < groupIndices.length; i++) {
                  int index = groupIndices[i];
                  if (index == modifiedIndex && remove) {
                      throw new IllegalStateException(
                              "The removed index " + modifiedIndex + " must not be grouped.");
                  } else if (index >= modifiedIndex) {
                      groupIndices[i] += offset;
                  }
              }
          }
      }
docs: Adjusts group indices. Shifts the given groups to left, right, up, down according to the
  specified remove or add flag.
  
  @param allGroupIndices the groups to be adjusted
  @param modifiedIndex the modified column or row index
  @param remove	true for remove, false for add
  @throws IllegalStateException if we remove and the index is grouped