Move finding all shortest paths to its own function. Added flow control to handle when done exploring and for nodes that could not be reached.