utility to flatten nested IOs