buildSolution :: [((Node, Node),(Float, Float))] -> Path -> IO Path
buildSolution xs solution =
  if all (\n -> isVisited solution n) (nub (map (fst.fst) xs))
  then return solution
  else do
         next <- nextToVisit solution xs
         buildSolution xs (visitNode solution next)
buildSolution :: [((Node, Node),(Float, Float))] -> Path -> IO Path
buildSolution xs solution =
  if all (\n -> isVisited solution n) (nub (map (fst.fst) xs))
  then return solution
  else do
         next <- nextToVisit solution xs
         buildSolution xs (visitNode solution next)
buildSolution xs solution =
  if all (\n -> isVisited solution n) (nub (map (fst.fst) xs))
  then return solution
  else do
         next <- nextToVisit solution xs
         buildSolution xs (visitNode solution next)