def get_choice_by_name(choices, name):
    """
    Find choices by name (with spaces or without spaces) or by raw_name.
    """
    try:
        return choices.from_name(name.replace(' ', '_').lower())
    except ValueError:
        for choice_id, choice_name in choices():
            choice = choices.from_id(choice_id)
            if choice.raw == name:
                return choice
        raise
