Convert `mergeLeaves` to Cadence.

See #375.