This question can be solved in 2 different approaches. The first approach is using Dynamic Programming, and the second approach this using Greedy algorithm approach.
$Algorithm$$:$
- Create an empty set $A$.
- Append all leaves $l \in T$ to $A$.
- Remove all the leaves $l$, their parents, and their grandparents from $T$.
- Repeat steps 2 and 3.
The correctness of this algorithm is classic. We can always prove that every leaf $l \in T$ is always in the set $A$.
This can be done using 'Proof by Contradiction'.
Assume that $A_{OPT}$ is the maximal set of nodes that suffice the condition of the question. Denote the cardinality of $|A_{OPT}| = c$. Assume by contradiction that there exist a leaf $l' \notin A$.
Consider the case where $l' \notin A_{OPT}$, $parent(l') \notin A_{OPT}$, and $grandParent(l') \notin A_{OPT}$. Then, we can append $l'$ to the set $A_{OPT}$ and get that $|A_{OPT}| = c + 1$, thus contradicting the assumption that $A_{OPT}$ was the maximal set of vertices that suffice the question's condition.
Consider the case where one of its grandparents is in A. Thus, we could remove its grandparent from $A_{OPT}$ and append $l'$ to $A_{OPT}$.