dfs+stack, keep tracking sum value at each node