graph theory conventions, difference between a PATH and a GRAPH?
Your algorithm returns a cycle rather than a path.

Here is a cycle:



Here is a path:



(Both images taken from Wikipedia.)

To get a path from the cycle, simply remove one edge (this is my best guess for what return a path of that cycle means).

Let me also mention that your algorithm is very inefficient. A much better choice is to use BFS/DFS.