Fixed infinite loop in path finding when weighting visited nodes.