Change the approach to finding paths in a forest.
Use BFS for finding paths in trees.
Add logic for finding a common ancestor of two vertices in a tree.