I suggest you do a "Delete Useless Elements" first to remove anything that's not needed. Any identical geometry that is left will have children and will need to be Replaced before deleting.
Yes, unused element are no problem.
But how to find these identical/duplicates elements that are used?
Say you have about 3000 elements in a model and 200 of them are duplicates.
Just an idea...maybe you can check...what about finding the center of gravity for each surface ? And if they have same coordinate see them if they are identical...probability to be different is very small I believe.
It seems like this would be a lot of work to write. I think you would need to do something like:
(Talking GSD only)
-collect all geosets in part
-collect all hybridshapes in all geosets
-get the first hybridshapes' inputs ***
-get the first hybridshapes' typename
-loop through the rest of the hybrid shapes in the part
-if the typename of subsequent hybridshapes matches the first, check to see if the inputs are the same
-repeat for all hybridshapes in part
But as Ferdo mentions, this may not be enough. You would need a way to detect geometric differences like what if one join removes sub elements and another join of the same inputs does not? Or if surfaces are split to save one side then the same surfaces are split to save the other side? You would also need to compare each features parameters, like if propagation was turned on or off.
***you would need to interrogate inputs for each feature, but each features inputs are exposed with different functions. I.e. For a join (hybridshapeassemble) you can get the number of elements joined by using the GetElementsSise function, then loop through the inputs using the GetElements function. An extracts inputs could be exposed using element or support.