code: protected void searchNode(P target, KdTree.Node n) {
  		while( n != null) {
  			checkBestDistance(n, target);
  
  			if( n.isLeaf() )
  				break;
  
  			// select the most promising branch to investigate first
  			KdTree.Node nearer,further;
  
  			double splitValue = distance.valueAt( (P)n.point , n.split );
  
  			if( distance.valueAt( target , n.split ) <= splitValue ) {
  				nearer = n.left;
  				further = n.right;
  			} else {
  				nearer = n.right;
  				further = n.left;
  			}
  
  			// See if it is possible for 'further' to contain a better node
  			double dx = splitValue - distance.valueAt(target, n.split );
  			if( further != null && canImprove(dx*dx) ) {
  				addToQueue(dx*dx, further, target );
  			}
  
  			n = nearer;
  		}
  	}
docs: Traverse a node down to a leaf.  Unexplored branches are added to the priority queue.