comefrom: <garvit244>145_2.py
code: def postorderTraversal( root):
      if not root:
          return []
      
      stack, result = [], []
      
      while True:
          while root:
              if root.right:
                  stack.append(root.right)
              stack.append(root)
              root = root.left
      
          root = stack.pop()
      
          if root.right and stack and stack[-1] == root.right:
              stack.pop()
              stack.append(root)
              root = root.right
          else:
              result.append(root.val)
              root = None
      
          if  len(stack)<=0:
              break
      
      return result
masked: def sample_funcname ( var_0 ) :
      if not var_0 :
          return [ ]
      var_1 , var_2 = [ ] , [ ]
      while True :
          while var_0 :
              if var_0.right :
                  var_1.append ( var_0.right )
              var_1.append ( var_0 )
              var_0 = var_0.left
          var_0 = var_1.pop ( )
          if var_0.right and var_1 and var_1 [ - 1 ] == var_0.right :
              var_1.pop ( )
              var_1.append ( var_0 )
              var_0 = var_0.right
          else :
              var_2.append ( var_0.val )
              var_0 = None
          if len ( var_1 ) <= 0 :
              break
      return var_2
  