How to find maximum matching edges in undirected tree
It is correct and runs in linear time. You can run a DFS to find the height and the parent node  of each vertex and visit the vertices according to their heights in ascending order.

The correctness of such algortihms is usually proved using an exchange argument. Assume $M$ is the matching computed by your algortihm and $M_{\mathrm{OPT}}$ an arbitrary maximum matching. Show that you can turn $M_{\mathrm{OPT}}$ into $M$ by removing and adding edges to the matching where its size never gos smaller.