-- | The list of all labels directly continued to by the given path. May contain
-- duplicates, if there are two continues to the same label.
continues :: (Ord c) => Path c b e a -> [c]
continues g = case g of
  _ :>> x      -> continues x
  Branch _ x y -> continues x ++ continues y
  Continue c   -> [c]
  End _        -> []

-- | @unroll l x g@ finds all places where @g@ continues to the label @l@, and
-- replaces them with the path @x@.
continues :: (Ord c) => Path c b e a -> [c]
continues g = case g of
  _ :>> x      -> continues x
  Branch _ x y -> continues x ++ continues y
  Continue c   -> [c]
  End _        -> []

-- | @unroll l x g@ finds all places where @g@ continues to the label @l@, and
-- replaces them with the path @x@.
continues g = case g of
  _ :>> x      -> continues x
  Branch _ x y -> continues x ++ continues y
  Continue c   -> [c]
  End _        -> []

-- | @unroll l x g@ finds all places where @g@ continues to the label @l@, and
-- replaces them with the path @x@.