Merge the two consecutive facet-generation loops into one.