def _find_routine_config(config, instance, routine_name):
    """Attempts to find the config for a routine based on the bases of the
    class of the instance.
    """
    bases = instance.__class__.__mro__
    for base in bases:
        full_name = '{}.{}'.format(base.__module__, base.__name__)
        if full_name not in config['patch']:
            continue
        config_routines = config['patch'][full_name]['routines']
        if routine_name in config_routines:
            return config_routines[routine_name]
    return {}
