Flatten an array or array-like object