private void searchNearestRecursively(double[] vec, KDTreeNode root){
		if(root == null)
			return;
		int split = root.split_dimension;
		double dist = MatrixUtils.calcDist(vec, root.vec);
		if(dist<nearestDistance){
			nearestDistance = dist;
			nearestData = root.vec;
		}
		if(vec[split]<=root.vec[split])
			searchNearestRecursively(vec, root.left);
		else
			searchNearestRecursively(vec, root.right);
		if(Math.abs(vec[split]-root.vec[split])<nearestDistance){
			if(vec[split]<=root.vec[split])
				searchNearestRecursively(vec, root.right);
			else
				searchNearestRecursively(vec, root.left);
		}
	}