When using a GMail account, new emails will appear in multiple folders: Inbox, [Gmail]/All Mail, and [Gmail]/Important. It should be trivial to automatically detect when receiving duplicate emails and delete all except in Inbox.
This sounds like an XY problem. Instead of "automatically detecting and deleting" duplicates mails (I can easily imagine how this could go wrong and delete lots of non-duplicated mails), akonadi should strive to _not_ duplicate the mails in the first place!
I'm adding a comment here instead of creating a new issue, since under Debian Bullseye with akonadi and kmail version `4:19.08.3-1`, I'm getting mail duplicates only in a very specific situation ; If I open kmail on two different computers at the same time (ie. on my laptop and my workstation). If only one akonadi server is running on both computers, then everything is fine. However if I run akonadi server on both computers, everything goes haywire and kmail starts spewing lots (LOTS!..in the hundreds) of duplicates mails. I hope this helps figuring out any race condition that might happen.