code: function computeHeight(revs) {
    var height = {};
    var edges = [];
    pouchdbMerge.traverseRevTree(revs, function (isLeaf, pos, id, prnt) {
      var rev = pos + "-" + id;
      if (isLeaf) {
        height[rev] = 0;
      }
      if (prnt !== undefined) {
        edges.push({from: prnt, to: rev});
      }
      return rev;
    });
  
    edges.reverse();
    edges.forEach(function (edge) {
      if (height[edge.from] === undefined) {
        height[edge.from] = 1 + height[edge.to];
      } else {
        height[edge.from] = Math.min(height[edge.from], 1 + height[edge.to]);
      }
    });
    return height;
  }
docs: for every node in a revision tree computes its distance from the closest leaf