Let's try to prove that there are exactly two vertices in $P$ such that those vertices have degree $1$. If we prove that, obviously, these vertices will be $v_0$ and $v_n$. And this will give us even more general result.
Suppose for a contradiction, there are more than two vertices such that degree of those vertices are $1$ in $P$. Then, by definition of path, all of those vertices must be either start or terminal vertices, which is a contradiction because a path in a tree has only one start and one terminal vertex (since it cannot be a circuit).
Now, suppose for a contradiction, there are less than two vertices with degree $1$ in the path. Since it is a tree, it cannot be zero because if it was zero, we would have a cycle. If the number of vertices with degree $1$ is one, then this is contradicting the assumption that $P$ is the longest path because the vertex with degree $1$ is $v_0$ and if there is no other vertex with degree $1$, then $d(v_n) > 1$ so it is not terminal at all. Therefore, there must be exactly two vertices with degree $1$ in longest path in tree and those are $v_0$ and $v_n$, obviously.