Question: Shortest path using while loop?

Modify the shortest path problem by rewriting a procedure Path, non-Recursion
 that print out the shortest path from a to e base on the information from
 setShortestDistNode
 input:  destination "e" and setShortestDistNode
 output:  path : a -> b -> d -> e the total cost: 9
hint: copy everything that we did in shortest path problem, and rewriting a procedure Path, with while loop

I'm assuming this means this, but I can't figure out how to change this to a while loop:
Path := proc (NodeName::character, setS) local elementNode;
if NodeName = "a" then return "a" else for elementNode in setS do if NodeName = elementNode[1]
then return procname(elementNode[2], setS), elementNode[1] end if end do end if end proc

Please Wait...