Algorithm for maximum independent set in trees
Lemma. Every tree $T$ with at least three vertices has a maximum-cardinality independent set which includes all its leaves.

Proof. Let $I$ be a maximum-cardinality independent set containing the greatest number of leaves of&nbsp;$T$ of all such independent sets. Suppose that $v\notin I$ for some leaf&nbsp;$v$ of&nbsp;$T$ and let $w$ be $v$'s unique neighbour. If $w\notin I$, then $I\cup\{v\}$ is independent, contradicting the supposed maximality of&nbsp;$I$. Otherwise, $w\in I$ but $I' = (I\setminus\{w\}) \cup \{v\}$ is an independent set of the same cardinality as&nbsp;$I$. Since $T$&nbsp;has at least three vertices, $w$&nbsp;has degree at least two, so is not a leaf. Therefore, $I'$&nbsp;contains one more leaf than&nbsp;$I$, again contradicting the choice of $I$. $\square$

Now we can see that the algorithm proposed in the question produces a maximum-cardinality independent set because it actually mimics a particular set of choices by the dynamic programming algorithm. Let $v$ and&nbsp;$w$ be vertices in the tree at maximal distance (which must, of course, be leaves). By the lemma, there is a maximum-cardinality independent set that includes both of these vertices. Therefore, we can pick either one to add to our independent set.

Note that there is a slight wrinkle in the algorithm as presented in the question. Suppose $v$ and&nbsp;$w$ are at maximal distance in&nbsp;$T$ and we decide to add&nbsp;$v$ to our independent set.  We delete $v$ and its neighbour&nbsp;$v'$ from&nbsp;$T$. However, if $v'$&nbsp;had degree at least three, we have disconnected the tree.  This is OK because, by maximality of the distance from $v$ to&nbsp;$w$, all but one of the neighbours of&nbsp;$v'$ must have been leaves, so all but one of the components of $T-\{v,v'\}$ are isolated vertices. But these isolated vertices must also be added to the independent set and deleted from&nbsp;$T$.  If they are not, then $d(v'',x)=\infty$ for any isolated vertex&nbsp;$v''$ and any other vertex&nbsp;$x$. Thus, the algorithm would be entitled to add any vertex&nbsp;$x$ to the independent set at the next step, which is not guaranteed to lead to a maximum-cardinality independent set (and, indeed, might disconnect the graph even more when we delete it and its neighbours).