def _f(x, t, s, cls):
    """Return True if x equals t,
    or x is an instance of cls and x equals cls(t),
    or x.lower().startswith(s)"""
    return x == t or \
            (isinstance(x, cls) and x == cls(t)) or \
            (isinstance(x, str) and x.lower().startswith(s))