docs: private CASHInterval doDetermineNextIntervalAtMaxLevel(ObjectHeap<CASHInterval> heap) {
      CASHInterval interval = heap.poll();
      int dim = interval.getDimensionality();
      while(true) {
        // max level is reached
        if(interval.getLevel() >= maxLevel && interval.getMaxSplitDimension() == (dim - 1)) {
          return interval;
        }
  
        if(heap.size() % 10000 == 0 && LOG.isVerbose()) {
          LOG.verbose("heap size " + heap.size());
        }
  
        if(heap.size() >= 40000) {
          LOG.warning("Heap size > 40.000! Stopping.");
          heap.clear();
          return null;
        }
  
        if(LOG.isDebuggingFiner()) {
          LOG.debugFiner("split " + interval.toString() + " " + interval.getLevel() + "-" + interval.getMaxSplitDimension());
        }
        interval.split();
  
        // noise
        if(!interval.hasChildren()) {
          return null;
        }
  
        CASHInterval bestInterval;
        if(interval.getLeftChild() != null && interval.getRightChild() != null) {
          int comp = interval.getLeftChild().compareTo(interval.getRightChild());
          if(comp < 0) {
            bestInterval = interval.getRightChild();
            heap.add(interval.getLeftChild());
          }
          else {
            bestInterval = interval.getLeftChild();
            heap.add(interval.getRightChild());
          }
        }
        else if(interval.getLeftChild() == null) {
          bestInterval = interval.getRightChild();
        }
        else {
          bestInterval = interval.getLeftChild();
        }
  
        interval = bestInterval;
      }
    }