If is null (no node exists), both states return . You cannot rob a house that does not exist.
if v is null then
return (0, 0)
This base case handles leaf nodes' children and empty subtrees. From here, you build up: leaves compute their DP from null children, parents compute from children, and so on up to the root. The final answer is max(dp[root][0], dp[root][1]).