Added a function to reconstruct the original path.