code: function (rect, root) {
      var bestChoiceIndex = -1;
      var bestChoiceStack = [];
      var bestChoiceArea;
      var first = true;
      bestChoiceStack.push(root);
      var nodes = root.nodes;
  
      while (first || bestChoiceIndex !== -1) {
        if (first) {
          first = false;
        } else {
          bestChoiceStack.push(nodes[bestChoiceIndex]);
          nodes = nodes[bestChoiceIndex].nodes;
          bestChoiceIndex = -1;
        }
  
        for (var i = nodes.length - 1; i >= 0; i--) {
          var ltree = nodes[i];
          if ('leaf' in ltree) {
            // Bail out of everything and start inserting
            bestChoiceIndex = -1;
            break;
          }
          // Area of new enlarged rectangle
          var oldLRatio = rectangle.squarifiedRatio(ltree.w, ltree.h, ltree.nodes.length + 1);
  
          // Enlarge rectangle to fit new rectangle
          var nw = Math.max(ltree.x + ltree.w, rect.x + rect.w) - Math.min(ltree.x, rect.x);
          var nh = Math.max(ltree.y + ltree.h, rect.y + rect.h) - Math.min(ltree.y, rect.y);
  
          // Area of new enlarged rectangle
          var lratio = rectangle.squarifiedRatio(nw, nh, ltree.nodes.length + 2);
  
          if (bestChoiceIndex < 0 || Math.abs(lratio - oldLRatio) < bestChoiceArea) {
            bestChoiceArea = Math.abs(lratio - oldLRatio);
            bestChoiceIndex = i;
          }
        }
      }
  
      return bestChoiceStack;
    }
docs: /* choose the best damn node for rectangle to be inserted into
  [ leaf node parent ] = chooseLeafSubtree(rectangle, root to start search at)
  @private