The Max Depth problem introduced you to Tree DP. The pattern is always the same:
Define what you want to compute for each node.
Express it in terms of the answers for the children.
Write a recursive function that combines child results.
Tree DP is bottom-up: you solve for leaves first, then combine results as you return up the tree. Many tree problems fit this pattern: subtree sizes, diameters, path sums, and more. Once you see the pattern, you can apply it everywhere.