class KDTree {

    public RealVector[] getMinMaxDistanceVectors(Datum queryDatum) {
        double[] minDifferences = new double[k];
        double[] maxDifferences = new double[k];

        RealVector metrics = queryDatum.metrics();
        for (int i=0; i<k; i++) {
            double deltaLo = metrics.getEntry(i) - this.boundaries[i][0];
            double deltaHi = this.boundaries[i][1] - metrics.getEntry(i);
            // point is outside
            double minD = Math.abs(deltaLo);
            double maxD = Math.abs(deltaHi);
            if (minD < maxD) {
                minDifferences[i] = minD;
                maxDifferences[i] = maxD;
            } else {
                minDifferences[i] = maxD;
                maxDifferences[i] = minD;
            }

            if (deltaLo > 0 && deltaHi > 0) {
                // Point is inside so only add to max distance.
                minDifferences[i] = 0;
            }
        }

        RealVector[] rtn = new RealVector[2];
        rtn[0] = new ArrayRealVector(minDifferences);
        rtn[1] = new ArrayRealVector(maxDifferences);
        return rtn;
    }

    public  KDTree(List<Datum> data, int leafCapacity);

}