All family instance in a same modelgroup type

Hello, i have a question i dont know if it is possible so i here for some help.

i have a array of families, some elements are in a group but i need every family in the same group instance. so that i have the same amount if groups as the family instance.



What defines what elements fall into what groups?