Before reading the solution, think:
What states do you need? For each node u, what decisions affect the answer? (Hint: Does u use an edge to its parent?)
How do you combine child states? If u does not use edge to parent, what can children do? If u does use it, what happens to one child?
what is the recurrence? Write dp[u][0] and dp[u][1] in terms of children.
Try to define the states clearly: 'dp[u][] means.' and 'dp[u][] means.'. Then write the transitions. Spend minute thinking. Then continue.