How to count outermost groups of grouped obects

I posted a script in this thread today for a similar question… Main thing to note as (as Pascal also mentioned) - I do not know how the algorithm figures out which is the “top level group”, so I’m not sure it will always get it right.

Another plan of attack here would be to perhaps modify your habits or those of your users and use something like layers, which are definitely hierarchical, to “group” objects rather than groups themselves. Another possibility would be to name your objects according to their “group” and then do by-name selections.

–Mitch