Here's the core pattern: = some combination of for all children of . For leaves (nodes with no children), comes directly from the node's properties.
For internal nodes, you combine children's dp values according to the problem's logic. The answer is usually , representing the solution for the entire tree. Sometimes you track a global maximum across all nodes instead.