def evaluate_group(flags):
    """evaluate group will take a list of flags (eg:

        [True, and, False, or, True]

       And read through the logic to determine if the image result
       is to be flagged. This is how we combine a set of criteria in
       a group to come to a final decision.
    """
    flagged = False
    first_entry = True
    while len(flags) > 0:
        flag = flags.pop(0)
        if flag == 'and':
            flag = flags.pop(0)
            flagged = flag and flagged
        elif flag == 'or':
            flag = flags.pop(0)
            flagged = flag or flagged
        elif first_entry is True:
            flagged = flag
        else:
            flagged = flagged and flag
        first_entry = False
    return flagged
