The basic problem is the materials need to be removed last since they depend on groups owning them. But it seems like the removal functions both need to run after the uniqueness ones. I don't know. It might need more thought. (Another thing I just removed is the propEqual function tests for PropSelection/Visibility which are more than likely to only foil a test in real scenario... this is hardly used, but I changed the default to "PropAllSuitable" to remove these from the propEqual parameter defaults. This clean up function is the only thing that uses propEqual that I can see.)
https://github.com/zturtleman/mm3d/blob/53b0d1b33412bddacd65559f41d5511b9050a27a/src/implui/groupclean.cc#L73-L88
The basic problem is the materials need to be removed last since they depend on groups owning them. But it seems like the removal functions both need to run after the uniqueness ones. I don't know. It might need more thought. (Another thing I just removed is the propEqual function tests for PropSelection/Visibility which are more than likely to only foil a test in real scenario... this is hardly used, but I changed the default to "PropAllSuitable" to remove these from the propEqual parameter defaults. This clean up function is the only thing that uses propEqual that I can see.)