Corrected a bug in merge-tree algorithm.