public ArrayList<ArrayList<Integer>> pathSumItr(TreeNode root, int sum) {
		// IMPORTANT: Please reset any member data you declared, as
		// the same Solution instance will be reused for each test case.
		// DFS

		ArrayList<ArrayList<Integer>> res = new ArrayList<ArrayList<Integer>>();
		if (root == null)
			return res;
		TreeNode node = root;
		Stack<TreeNode> stack = new Stack<TreeNode>();
		stack.push(root);
		ArrayList<Integer> tmp = new ArrayList<Integer>();
		HashSet<TreeNode> visited = new HashSet<TreeNode>();
		while (!stack.isEmpty()) {
			node = stack.peek();
			if (visited.contains(node)) {
				stack.pop();
				sum += node.val;
				tmp.remove(tmp.size() - 1);
				continue;
			}
			visited.add(node);
			tmp.add(node.val);
			sum -= node.val;
			if (node.right == null && node.left == null) {
				if (sum == 0) {
					res.add(new ArrayList<Integer>(tmp));
				}
				sum += node.val;
				tmp.remove(tmp.size() - 1);
				stack.pop();
			} else {
				if (node.right != null)
					stack.push(node.right);
				if (node.left != null)
					stack.push(node.left);
			}
		}
		return res;
	}