def collect_unioned_set_field(block_structure, transformer, merged_field_name, filter_by):
 for block_key in block_structure.topological_traversal():
  result_set = ({block_key} if filter_by(block_key) else set())
  for parent in block_structure.get_parents(block_key):
   result_set |= block_structure.get_transformer_block_field(parent, transformer, merged_field_name, set())
  block_structure.set_transformer_block_field(block_key, transformer, merged_field_name, result_set)

def collect_unioned_set_field ( block_structure , transformer , merged_field_name , filter_by ) : for block_key in block_structure . topological_traversal ( ) : result_set = ( { block_key } if filter_by ( block_key ) else set ( ) ) for parent in block_structure . get_parents ( block_key ) : result_set |= block_structure . get_transformer_block_field ( parent , transformer , merged_field_name , set ( ) ) block_structure . set_transformer_block_field ( block_key , transformer , merged_field_name , result_set )
recursively union a set field on the block structure .