hierarchical groups

added simple algo to try and group the groups