GEOS-5672: fixed nested group loop

Hi,
I've fixed (again) GEOS-5672.