docs: protected void findNearestNeighbours(Instance target, KDTreeNode node, int k,
        MyHeap heap, double distanceToParents) throws Exception {
      if (node.isALeaf()) {
        double distance;
        // look at all the instances in this leaf
        for (int idx = node.m_Start; idx <= node.m_End; idx++) {
          if (target == m_Instances.instance(m_InstList[idx])) // for
                                                                // hold-one-out
                                                                // cross-validation
            continue;
          if (heap.size() < k) {
            distance = m_EuclideanDistance.distance(target, m_Instances
                .instance(m_InstList[idx]), Double.POSITIVE_INFINITY);
            heap.put(m_InstList[idx], distance);
          } else {
            MyHeapElement temp = heap.peek();
            distance = m_EuclideanDistance.distance(target, m_Instances
                .instance(m_InstList[idx]), temp.distance);
            if (distance < temp.distance) {
              heap.putBySubstitute(m_InstList[idx], distance);
            } else if (distance == temp.distance) {
              heap.putKthNearest(m_InstList[idx], distance);
            }
          }// end else heap.size==k
        }// end for
  
      } else {
        KDTreeNode nearer, further;
        boolean targetInLeft = m_EuclideanDistance.valueIsSmallerEqual(target,
            node.m_SplitDim, node.m_SplitValue);
  
        if (targetInLeft) {
          nearer = node.m_Left;
          further = node.m_Right;
        } else {
          nearer = node.m_Right;
          further = node.m_Left;
        }
        findNearestNeighbours(target, nearer, k, heap, distanceToParents);
  
        // ... now look in further half if maxDist reaches into it
        if (heap.size() < k) { // if haven't found the first k
          double distanceToSplitPlane = distanceToParents
              + m_EuclideanDistance.sqDifference(node.m_SplitDim, target
                  .value(node.m_SplitDim), node.m_SplitValue);
          findNearestNeighbours(target, further, k, heap, distanceToSplitPlane);
          return;
        } else { // else see if ball centered at query intersects with the other
                  // side.
          double distanceToSplitPlane = distanceToParents
              + m_EuclideanDistance.sqDifference(node.m_SplitDim, target
                  .value(node.m_SplitDim), node.m_SplitValue);
          if (heap.peek().distance >= distanceToSplitPlane) {
            findNearestNeighbours(target, further, k, heap, distanceToSplitPlane);
          }
        }// end else
      }// end else_if an internal node
    }