[guided]We inspect each vertex $w \in N_T(x_k)$ and rule out every possibility except $w = x_{k-1}$.
First, a sanity check: $T$ is a simple graph by convention, so no loops, meaning $w \neq x_k$. And $w \in V(T)$, so $w$ is some vertex of $T$. We split according to where $w$ sits relative to the path $P$:
**Case A: $w$ is not on $P$**, i.e., $w \notin \{x_1, x_2, \ldots, x_k\}$.
Then we can **extend** $P$ by tacking $w$ onto its end. Consider the sequence
\begin{align*}
x_1, x_2, \ldots, x_k, w.
\end{align*}
The vertices are pairwise distinct: $x_1, \ldots, x_k$ are distinct because $P$ is a path, and $w$ is distinct from all of them because $w \notin \{x_1, \ldots, x_k\}$. Every consecutive pair is an edge of $T$: the pairs $x_{i-1} x_i$ for $2 \le i \le k$ because $P$ is a path in $T$, and the new pair $x_k w$ because $w \in N_T(x_k)$. Hence this sequence is a path in $T$. Its length is $k$ (number of edges). But $P$ was chosen to be a path of maximum length $k - 1 < k$. Contradiction.
**Case B: $w = x_i$ for some $i \in \{1, 2, \ldots, k - 2\}$.**
Then we can **close a cycle** using the segment of $P$ from $x_i$ to $x_k$ and the new edge $x_k w = x_k x_i$. Consider
\begin{align*}
C = x_i, x_{i+1}, \ldots, x_{k-1}, x_k, x_i.
\end{align*}
Let us verify this is a cycle. The internal vertex list $x_i, x_{i+1}, \ldots, x_k$ consists of distinct vertices of $P$. The consecutive pairs
\begin{align*}
x_i x_{i+1},\ x_{i+1} x_{i+2},\ \ldots,\ x_{k-1} x_k
\end{align*}
are edges of $T$ from the path $P$, and the closing pair $x_k x_i$ is the edge $x_k w$, which lies in $T$ because $w \in N_T(x_k)$. The length is $(k - i) + 1$, where $k - i \ge 2$ since $i \le k - 2$, so the length is at least $3$. Therefore $C$ is a cycle in $T$. But $T$ is acyclic. Contradiction.
**Why we need $i \le k - 2$ and not merely $i \le k - 1$.** The case $i = k - 1$ would give the "closed walk" $x_{k-1}, x_k, x_{k-1}$, which is not a cycle — it has length $2$, and a cycle must have length at least $3$. So $w = x_{k-1}$ is allowed; it corresponds to the edge $x_{k-1} x_k$ already on $P$ and creates no cycle. This is why $i = k - 1$ is excluded from Case B.
**Case C: $w = x_{k-1}$.** This is permitted: the edge $x_{k-1} x_k$ is already an edge of $P$, and we cannot rule it out using maximality or acyclicity.
Combining the cases, the only admissible neighbour of $x_k$ is $x_{k-1}$, so $N_T(x_k) = \{x_{k-1}\}$ and $\deg_T(x_k) = 1$, i.e., $x_k$ is a leaf.[/guided]