def filter_damaged_taxa(df, filter_conditions, taxonomic_rank):
    """Function to filter damaged taxa

    Args:
        df (panda.DataFrame): A dataframe containing metaDMG results
        filter_conditions (dict): A dictionary with filter conditions
        taxonomic_rank (str): Select the taxonomic rank to filter

    Returns:
        pandas.DataFrame: A filtered dataframe containing metaDMG results
    """
    # filter rows by d_max, phi, qvalue
    mdmg_results = df.loc[
        (df["D_max"] >= filter_conditions["d_max"])
        & (df["phi"] >= filter_conditions["phi"])
        & (df["q"] >= filter_conditions["q"])
        & (df["tax_rank"] == taxonomic_rank)
    ]

    return mdmg_results