Trees with minimal index and diameter at most four