Implement flat_map without extending objects, and supporting yielding to
a block.