def postorder_traversal_iterative(root):
    """
    Return the postorder traversal of nodes' values.

    - Worst Time complexity: O(n)
    - Worst Space complexity: O(n)

    :param root: root node of given binary tree
    :type root: TreeNode or None
    :return: postorder traversal of nodes' values
    :rtype: list[int]
    """
    # basic case
    if root is None:
        return []

    # use stack to traverse
    result = []
    stack = [root]
    prev = None
    while len(stack) != 0:
        curr = stack[-1]
        no_child = curr.left is None and curr.right is None
        child_visited = prev is not None and \
                        (curr.left == prev or curr.right == prev)
        if no_child or child_visited:
            result.append(curr.val)
            stack.pop()
            prev = curr
        else:
            if curr.right is not None:
                stack.append(curr.right)
            if curr.left is not None:
                stack.append(curr.left)

    return result