Rename block_ter to iter_blocks and refactor.

Fixed a bug that prevented the nested components of if/else statements from
being generated.