# Pastebin kEKQJccG follow _ [] = [] follow hp sns@(Knot p s:knots) | touching hp p = sns | otherwise = let np = towardsHead p hp in Knot np (Set.insert np s) : follow np knots