Added `flatten_once` function