public ArrayList<ArrayList<Integer>> levelOrderBottom(TreeNode root) {

        ArrayList<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>();
        ArrayList<Integer> row = new ArrayList<Integer>();

        if (root == null) {
            return result;
        }

        TreeIterator iterator = new TreeIterator(root);

        while (iterator.hasNext()) {
            TreeNode current = iterator.next();
            if (current == null) {
                result.add(row);
                row = new ArrayList<Integer>();
            }
            else {
                row.add(current.val);
            }
        }
        Collections.reverse(result);
        return result;
    }