def set_record_topology(record, topology, pass_if_already_set=False):
    """Set record.annotations['topology'] (if not already set?)"""
    record_topology = record.annotations.get('topology', None)
    do_nothing = pass_if_already_set and record_topology is not None
    if not do_nothing:
        record.annotations['topology'] = topology
