code: function bubble_down(i) {
      var l = left(i);
      var r = right(i);
  
      /* as long as there are smaller children */
      while (tree[l] && tree[i][key] > tree[l][key] || tree[r] && tree[i][key] > tree[r][key]) {
  
        /* find smaller child */
        var child = tree[l] ? tree[r] ? tree[l][key] > tree[r][key] ? r : l : l : l;
  
        /* swap with smaller child with current element */
        tree[i] = tree.splice(child, 1, tree[i])[0];
  
        /* go up one level */
        i = child;
        l = left(i);
        r = right(i);
      }
    }
docs: /* Helper function to swap elements with the smaller of their children
  as long as there is one