docs: private void preInsert(RdKNNEntry q, RdKNNEntry nodeEntry, KNNHeap knns_q) {
      double knnDist_q = knns_q.getKNNDistance();
      RdKNNNode node = getNode(nodeEntry);
      double knnDist_node = 0.;
  
      // leaf node
      if(node.isLeaf()) {
        for(int i = 0; i < node.getNumEntries(); i++) {
          RdKNNLeafEntry p = (RdKNNLeafEntry) node.getEntry(i);
          double dist_pq = distanceQuery.distance(p.getDBID(), ((LeafEntry) q).getDBID());
  
          // p is nearer to q than the farthest kNN-candidate of q
          // ==> p becomes a knn-candidate
          if(dist_pq <= knnDist_q) {
            knns_q.insert(dist_pq, p.getDBID());
            if(knns_q.size() >= settings.k_max) {
              knnDist_q = knns_q.getKNNDistance();
              q.setKnnDistance(knnDist_q);
            }
  
          }
          // p is nearer to q than to its farthest knn-candidate
          // q becomes knn of p
          if(dist_pq <= p.getKnnDistance()) {
            KNNList knns_without_q = knnQuery.getKNNForObject(relation.get(p.getDBID()), settings.k_max);
            p.setKnnDistance(knns_without_q.size() + 1 < settings.k_max ? Double.NaN : //
                Math.min(knns_without_q.doubleValue(knns_without_q.size() - 1), dist_pq));
          }
          knnDist_node = Math.max(knnDist_node, p.getKnnDistance());
        }
      }
      // directory node
      else {
        O obj = relation.get(((LeafEntry) q).getDBID());
        List<DoubleObjPair<RdKNNEntry>> entries = getSortedEntries(node, obj, settings.distanceFunction);
        for(DoubleObjPair<RdKNNEntry> distEntry : entries) {
          RdKNNEntry entry = distEntry.second;
          double entry_knnDist = entry.getKnnDistance();
  
          if(distEntry.first < entry_knnDist || distEntry.first < knnDist_q) {
            preInsert(q, entry, knns_q);
            knnDist_q = knns_q.getKNNDistance();
          }
          knnDist_node = Math.max(knnDist_node, entry.getKnnDistance());
        }
      }
      nodeEntry.setKnnDistance(knnDist_node);
    }