code: function mergeTree(in_tree1, in_tree2) {
    var queue = [{tree1: in_tree1, tree2: in_tree2}];
    var conflicts = false;
    while (queue.length > 0) {
      var item = queue.pop();
      var tree1 = item.tree1;
      var tree2 = item.tree2;
  
      if (tree1[1].status || tree2[1].status) {
        tree1[1].status =
          (tree1[1].status ===  'available' ||
          tree2[1].status === 'available') ? 'available' : 'missing';
      }
  
      for (var i = 0; i < tree2[2].length; i++) {
        if (!tree1[2][0]) {
          conflicts = 'new_leaf';
          tree1[2][0] = tree2[2][i];
          continue;
        }
  
        var merged = false;
        for (var j = 0; j < tree1[2].length; j++) {
          if (tree1[2][j][0] === tree2[2][i][0]) {
            queue.push({tree1: tree1[2][j], tree2: tree2[2][i]});
            merged = true;
          }
        }
        if (!merged) {
          conflicts = 'new_branch';
          insertSorted(tree1[2], tree2[2][i], compareTree);
        }
      }
    }
    return {conflicts: conflicts, tree: in_tree1};
  }
docs: Merge two trees together The roots of tree1 and tree2 must be the same revision