This can be simplified to

    groupingSetIndex < groupingSets.size