add idx for each leaf node in ctree/dtree