KD tree implementation in Standard ML / MLton