Fixes a stack-overflow exception in expander's flatten.

Ran into this today.