implemented somewhat working KD-tree