Any node has a number of edges that lead to or from connected nodes. There is no such thing as a "previous node".

The number of edges of a node can be determined by path_getedge with increasing edge numbers until 0 is returned.

The nodes leading to the current node can be found by enumerating all nodes (path_getnode) and checking if an edge leads to the current node (path_nextnode).