public List<List<Integer>> levelOrderBottom(TreeNode root) {
        List<List<Integer>> allLevel = new ArrayList<List<Integer>>();
        Queue queue = new LinkedList();
        Queue sameLevel = new LinkedList();
        queue.offer(root);
        TreeNode p;
        List<Integer> level = new ArrayList<Integer>();

        while (!queue.isEmpty() && queue.peek() != null) {
            p = (TreeNode) queue.poll();
            level.add(p.val);
            if (p.left != null) {
                sameLevel.offer(p.left);
            }
            if (p.right != null) {
                sameLevel.offer(p.right);
            }
            if (queue.isEmpty()) {
                queue.addAll(sameLevel);
                sameLevel.clear();
                allLevel.add(level);
                level = new ArrayList<Integer>();
            }
        }

        return allLevel;
    }