private IndexTreePath < E > choosePath ( AbstractMTree < ? , N , E , ? > tree , E object , IndexTreePath < E > subtree ) { N node = tree . getNode ( subtree . getEntry ( ) ) ; // leaf if ( node . isLeaf ( ) ) { return subtree ; } // Initialize from first: int bestIdx = 0 ; E bestEntry = node . getEntry ( 0 ) ; double bestDistance = tree . distance ( object . getRoutingObjectID ( ) , bestEntry . getRoutingObjectID ( ) ) ; // Iterate over remaining for ( int i = 1 ; i < node . getNumEntries ( ) ; i ++ ) { E entry = node . getEntry ( i ) ; double distance = tree . distance ( object . getRoutingObjectID ( ) , entry . getRoutingObjectID ( ) ) ; if ( distance < bestDistance ) { bestIdx = i ; bestEntry = entry ; bestDistance = distance ; } } return choosePath ( tree , object , new IndexTreePath <> ( subtree , bestEntry , bestIdx ) ) ; }
Chooses the best path of the specified subtree for insertion of the given object .