(Bug 5080) Separate out pruning logic into a method, and add duplicate detection

This is a best guess based on exact server timestamp and subject. If
both match exactly, we figure that this was a previously imported entry,
or maybe crossposted entry, that is not linked properly (as an import /
crosspost) for some reason.