Create an "INSTANCEOF" Filter block from a CoerceType block.

def convert_coerce_type_to_instanceof_filter(coerce_type_block):
    """Create an "INSTANCEOF" Filter block from a CoerceType block."""
    coerce_type_target = get_only_element_from_collection(coerce_type_block.target_class)

    # INSTANCEOF requires the target class to be passed in as a string,
    # so we make the target class a string literal.
    new_predicate = BinaryComposition(
        u'INSTANCEOF', LocalField('@this'), Literal(coerce_type_target))

    return Filter(new_predicate)