Protect against infinitely recursing flatten.

Flatten one step at a time until we're as flat as we can be, which prevents objects which break `flatten` from recursing infinitely. A workaround for #95.
s/infinetly/infinitely/