def enumerate_tagged_methods(instance, tag, expected_value=None):
    """Enumerates all methods of instance which has an attribute named tag."""

    methods = []
    for attr in dir(instance):
        value = getattr(instance, attr)
        if callable(value):
            try:
                tagged_value = getattr(value, tag)
            except AttributeError:
                continue
            if expected_value is None or tagged_value == expected_value:
                methods.append(value)
    else:
        return methods