public List<List<Integer>> levelOrderBottom(TreeNode root) {
    List<List<Integer>> res = new LinkedList<List<Integer>>();
    if(root == null) return res;
    TreeNode END = new TreeNode(0);
    Queue<TreeNode> queue = new LinkedList<TreeNode>();
    Stack<List<Integer>> stack = new Stack<List<Integer>>();
    List<Integer> level = new LinkedList<Integer>();
    queue.add(root);
    queue.add(END);
    while(!queue.isEmpty()){
      TreeNode node = queue.poll();
      if(node != END){
        level.add(node.val);
        if(node.left != null) queue.add(node.left);
        if(node.right != null) queue.add(node.right);
      } else {
        stack.add(new LinkedList<Integer>(level));
        level.clear();
        if(!queue.isEmpty()) queue.add(END);
      }
    }
    while(!stack.isEmpty()){
      res.add(stack.pop());
    }
    return res;
  }