Store the paths from u to v in an undirected unweighted tree iteratively

bfs
dfs
path
tree

#1

Given a undirected unweighted tree (Undirected acyclic graph) stored as adjacency list. I have to go from path u to path v and store all nodes in the path and use them
or use the values of nodes on the path stored in integer array.

I know how to use DFS and implement this but the problem is tree size is 2 \times 10^5 nodes and dfs recursion is giving stackoverflow error. How can I achieve this task.

Please help