def filter_most_specific(types):
    """From a list of types, determine the most specific ones.

    Args:
        types (list[type]): List of types.

    Returns:
        list[type]: Most specific types in `types`.
    """
    filtered_types = []

    while len(types) > 0:
        t, types = types[0], types[1:]

        # If `t` is a supertype, discard it. Otherwise, keep it.
        if not (
            any(issubclass(u, t) for u in types)
            or any(issubclass(u, t) for u in filtered_types)
        ):
            filtered_types.append(t)

    return filtered_types