The minimal index of trees with a small diameter