def flatten(xs):
    """
  Flatten any recursive list or tuple into a single list.

  For instance:
  - `flatten(x) => [x]`
  - `flatten([x]) => [x]`
  - `flatten([x, [y], [[z]]]) => `[x, y, z]`
  """
    if isinstance(xs, (list, tuple)):
        return [y for ys in [flatten(x) for x in xs] for y in ys]
    return [xs]