Is the goal to delete messages with the same subject line (but which may have different bodies), or messages that are fully duplicates (so same body, subject line, and most other headers)? "Duplicate" in the second case is a lot harder as you could have messages that the received headers are different but which are otherwise the same. To handle that case, I'd think you'd want to do:
1) Use scan or something similar to find messages with the same subject
2) Use a custom scan template (or resort to grep) to find messages within the previous set that have duplicated headers (presumably, to, from, subject, and perhaps a few others).
3) Within any duplicates that have passed test 2, then use mhstore or the like to extract the bodies, and use md5 or cmp to verify the bodies are the same too.