several (all exploding) methods of flattening, although the initial length check when flattening consumes very little memory