@pshizhsysu Great summary. Took me some minutes to figure out the if conditions within the postorder while loop:

`if (top->left != 0 && top->left != last_pop && top->right != last_pop)`

for pushing left child.`if (top->right != 0 && top->right != last_pop && (top->left == 0 || top->left == last_pop))`

for pushing right child.

First, we pop a node out of the stack only when the node is a leaf node or we have already poped the node's left and right children. Secondly, a node can be "looked" at, which is the `TreeNode* top = s.top()`

part, at most 3 times:

- the first time it is looked at.
- got returned back from the left subtree.
- got returned back from the right subtree.

We only add the node's left child when the left child is not `null`

and the node is looked at for the very first time. Thus, the first `if`

condition includes `top->left != last_pop && top->right != last_pop`

. Then, we only add the node's right child when the right child is not `null`

and the node is looked at when returning from the left subtree or left child is `null`

. Thus, the second `if`

condition includes `top->right != last_pop && (top-left == 0 || top->left == last_pop)`

. Hope this explanation helps others understand the code better.

Thanks.

Edit: We actually don't need the last part of the second `if`

condition, simply `if (top->right != 0 && top->right != last_pop)`

is enough.