get_all_pieces uses flatten and compact methods