def filter_matching_taxon_ids(query_set, taxon_id=None):
    """Filters out all instances with a taxonomy id that does not match
    `taxon_id` if taxon_id is not None. Taxonomy id must be one supported by
    `UniProt`.

    Parameters
    ----------
    query_set : :class:`Query`
        A query instance from `sqlalchemy`

    taxon_id : int, optional
        An integer taxonomy id supported by `UniProt`

    Returns
    -------
    :class:`Query`
        Filtered query instance.
    """
    if taxon_id is not None:
        return query_set.filter_by(taxon_id=taxon_id)
    else:
        return query_set