Asking every manager in a company "how many people report to you?": each asks their direct reports first, then adds them up.
Clues that point here
→ Binary tree input
→ Height, depth, diameter, path sums
→ "Same tree", "symmetric", "invert"
→ Answer depends on both subtrees
Not this pattern when
✕ The question is about levels or the shortest distance from the root (BFS)
The template
A skeleton to adapt. The parts in comments are what changes from problem to problem.
Tree DFS · template
int dfs(TreeNode node) {
if (node == null) return 0; // base case
int left = dfs(node.left);
int right = dfs(node.right);
return combine(node.val, left, right); // e.g. 1 + Math.max(left, right)
}