I did the exactly same. Something like this: E[] arr1 = rTree.rangeSearch(getRange(currentLoc)); E[] arr2 = kDTree.nearestNeighbor(currentLoc, arr1.length)