Mega thread are good since some replies are off-topic to the context of a current thread, but it's a good discussion concept, so mega threads could go a long way to accommodate every concept of a given topic of discussion.
Those threads were created by different users (OP) and therefore it's not possible to merge the different threads together.
Imagine that the moderators were to merge the threads together, who would be the OP of such intended mega thread when all the users were OP? That's why you should know that it won't be possible, or have you seen more than one OP in a thread?
The best solution is to lock a duplicate thread, if the OP of such duplicate thread would not lock it, it should be reported to moderators and they will lock it after analyzing the both thread and confirms that it exactly the same content.
In the case of how many OPs would be in one thread, I'm of the opinion that if it would be implemented, then any thread that is considered a duplicate, the OP attachment would be stripped off such a post and it would be reduced to an ordinary reply in the mega thread.
Why I don't really see locking the thread as a good solution is that the concept which is being introduced might be valid, although off-topic to the previous thread, so locking it might stop a useful discussion, but when the mods moves it to the mega thread as a reply, others can still contribute to it meaningfully.
Finally, there's nothing like "wont be possible" in the programming world, it's just a combination of time and efforts, every valid thought is achievable.