public void nearestN(final double[] key, final int n, final Callback<Object[]> callback) {

    HRect hr = HRect.infiniteHRect(key.length);
    double max_dist_sqd = Double.MAX_VALUE;

    NearestNeighborList nnl = new NearestNeighborList(n);
    Distance distance = getDistance();
    internalNearest(this, distance, key, hr, max_dist_sqd, 0, key.length, threshold, nnl);

    Object[] res = nnl.getAllNodes();
    callback.on(res);
  }