tweak tree to store the training data index in every leaf node