getCycle :: [Int] -> [Int]
getCycle nodes = getCycle' (tail nodes) []
  where
    firstNode = head nodes
    
    getCycle' :: [Int] -> [Int] -> [Int]
    getCycle' (node:nodes) acc
      | firstNode == node = node:acc
      | otherwise = getCycle' nodes (node:acc)
getCycle :: [Int] -> [Int]
getCycle nodes = getCycle' (tail nodes) []
  where
    firstNode = head nodes
    
    getCycle' :: [Int] -> [Int] -> [Int]
    getCycle' (node:nodes) acc
      | firstNode == node = node:acc
      | otherwise = getCycle' nodes (node:acc)
getCycle nodes = getCycle' (tail nodes) []
  where
    firstNode = head nodes
    
    getCycle' :: [Int] -> [Int] -> [Int]
    getCycle' (node:nodes) acc
      | firstNode == node = node:acc
      | otherwise = getCycle' nodes (node:acc)