00940fb8 changed this code to construct a set for the B metadata. However, it still performs a linear is_contained query, rather than making use of the set structure.