According to JCR 2.0 spec, p. "15.9 Merge", Merge operation should work correctly on nodes with versions that are "eventual successors" (i.e. source node's version is a non-linear descendant of target node's version).
Current implementation checks versions to be only linear (i.e. direct) successors of each other.
It should be changed to check successors recursively.