Reworked algorithm to find Possible paths to an endnode