}
// step 8
IKDTreeDomain nearest = null;
RefDouble distSq = new RefDouble();
if (nearerKd == null) {
distSq.val = Double.POSITIVE_INFINITY;
} else {
nearest = nearerKd.nearestNeighbourI(target, nearerHr, maxDistSq, distSq);
}
// step 9
maxDistSq = Math.min(maxDistSq, distSq.val);
// step 10
if (furtherHr.isInReach(target, Math.sqrt(maxDistSq))) {
double ptDistSq = KDTree.distanceSq(pivot, target);
if (ptDistSq < distSq.val) {
// steps 10.1.1 to 10.1.3
nearest = pivot;
distSq.val = ptDistSq;
maxDistSq = distSq.val;
}
// step 10.2
RefDouble tempDistSq = new RefDouble();
IKDTreeDomain tempNearest = null;
if (furtherKd == null) {
tempDistSq.val = Double.POSITIVE_INFINITY;
} else {
tempNearest = furtherKd.nearestNeighbourI(target, furtherHr, maxDistSq, tempDistSq);