Do txid duplicates check inside BuildMerkleRoot

Based on #4925.