GEOS-5672: fixed nested group loop

Hi,
I've fixed http://jira.codehaus.org/browse/GEOS-5672
Now groups are compared by id.