MORI-36: flatten on array

provide a version of flatten that can work on arrays