I have found that in some instances while using IMAP in apple mail it does duplicate messages. I believe in some cases this may be due to the archival mail function for deletion. No matter how many times you delete a message it reappears in your box you deleted it from, and also keeps duplicating the messages.
I was able to resolve the issue for a mailbox for one of my clients by turning off the mail archival feature in the account settings for the affected account.
Once the mail is deleted, feel free to turn the archival back on. You will still have to remove the duplicates by hand however. Also, make darn sure you mean to delete the messages you're deleting because once you delete them with these settings, they're gone.
More info:
The problem seems to stem from the operation of moving the file from one folder to another. In essence you're asking the server to move the mail from your mail box, to the trash. Mail seems to get excited about this some times and messes the whole thing up. After turning off this option, the mail program ran for hours deleting archived messages off the server. Total data of duplicated messages was 5.2GB
Good luck and happy computing.