recursive version of select_all_blocks