def match_barcode_rule(trello_db, barcode):
    """Finds a barcode rule matching the given barcode.

       Returns the rule if it exists, otherwise returns None."""
    for rule in trello_db.get_all('barcode_rules'):
        if rule['barcode'] == barcode:
            return rule
    return None