<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_ldap_filter(ldap_filter):
 # type: (Any) -> Optional[Union[LDAPFilter, LDAPCriteria]] """ Retrieves the LDAP filter object corresponding to the given filter. Parses it the argument if it is an LDAPFilter instance :param ldap_filter: An LDAP filter (LDAPFilter or string) :return: The corresponding filter, can be None :raise ValueError: Invalid filter string found :raise TypeError: Unknown filter type """

    if ldap_filter is None:
        return None

    if isinstance(ldap_filter, (LDAPFilter, LDAPCriteria)):
        # No conversion needed
        return ldap_filter
    elif is_string(ldap_filter):
        # Parse the filter
        return _parse_ldap(ldap_filter)

    # Unknown type
    raise TypeError(
        "Unhandled filter type {0}".format(type(ldap_filter).__name__)
    )