BIM Interoprability Tools uses the warning list in Revit to report back duplicates.
To find an remove duplicates there are several good posts on the forum - some which will even do the job in other ways as have been described. So there likely isn’t a need to reinvent the wheel in this case.
This thread has some good samples: Delete duplicated elements - #5 by bruce.buckland
You’ll have to update to a newer version, but it should get you what you’re after. In particular this post from @chuongmep works well (chrome can translate the language for you): Check Element Duplicate Dynamo Revit | Hồ Văn Chương