first version of moving KDTree from core to ml