code: public static Object groupKey(Object key, int groupLevel) {
          if (groupLevel > 0 && (key instanceof List) && (((List<Object>) key).size() > groupLevel)) {
              return ((List<Object>) key).subList(0, groupLevel);
          } else {
              return key;
          }
      }
docs: Returns the prefix of the key to use in the result row, at this groupLevel