hamt.js
function mergeLeaves(edit, shift, h1, n1, h2, n2) {
    if (h1 === h2) return Collision(edit, h1, [n2, n1]);

    var subH1 = hashFragment(shift, h1);
    var subH2 = hashFragment(shift, h2);
    return IndexedNode(edit, toBitmap(subH1) | toBitmap(subH2), subH1 === subH2 ? [mergeLeaves(edit, shift + SIZE, h1, n1, h2, n2)] : subH1 < subH2 ? [n1, n2] : [n2, n1]);
}
function mergeLeaves(edit, shift, h1, n1, h2, n2) {
    if (h1 === h2) return Collision(edit, h1, [n2, n1]);

    var subH1 = hashFragment(shift, h1);
    var subH2 = hashFragment(shift, h2);
    return IndexedNode(edit, toBitmap(subH1) | toBitmap(subH2), subH1 === subH2 ? [mergeLeaves(edit, shift + SIZE, h1, n1, h2, n2)] : subH1 < subH2 ? [n1, n2] : [n2, n1]);
}
function mergeLeaves ( edit , shift , h1 , n1 , h2 , n2 ) { if ( h1 === h2 ) return Collision ( edit , h1 , [ n2 , n1 ] ) ; var subH1 = hashFragment ( shift , h1 ) ; var subH2 = hashFragment ( shift , h2 ) ; return IndexedNode ( edit , toBitmap ( subH1 ) | toBitmap ( subH2 ) , subH1 === subH2 ? [ mergeLeaves ( edit , shift + SIZE , h1 , n1 , h2 , n2 ) ] : subH1 < subH2 ? [ n1 , n2 ] : [ n2 , n1 ] ) ; }
Merge two leaf nodes.

@param shift Current shift.
@param h1 Node 1 hash.
@param n1 Node 1.
@param h2 Node 2 hash.
@param n2 Node 2.
Merge two leaf nodes .