Fix topicmerge topic duplication error #1539

I used the files provided by @ToshihikoMakita in #1539 for testing.

I really wanted to add a unit test for this case, but I almost lost my mind trying to get XMLUnit to recognize two equal instances of XML as equal — it just wouldn't work. If you want, you can leave this PR open for now and I'll give it another shot later.