def _profile_exclusion(matching_profiles, logger):
    """Find out most matching profile byt host, task and family match.

    Profiles are selectively filtered. Each item in passed argument must
    contain tuple of (profile, profile's score) where score is list of
    booleans. Each boolean represents existence of filter for specific key.
    Profiles are looped in sequence. In each sequence are profiles split into
    true_list and false_list. For next sequence loop are used profiles in
    true_list if there are any profiles else false_list is used.

    Filtering ends when only one profile left in true_list. Or when all
    existence booleans loops passed, in that case first profile from remainded
    profiles is returned.

    Args:
        matching_profiles (list): Profiles with same scores. Each item is tuple
            with (profile, profile values)

    Returns:
        dict: Most matching profile.
    """

    logger.info(
        "Search for first most matching profile in match order:"
        " Host name -> Task name -> Family."
    )

    if not matching_profiles:
        return None

    if len(matching_profiles) == 1:
        return matching_profiles[0][0]

    scores_len = len(matching_profiles[0][1])
    for idx in range(scores_len):
        profiles_true = []
        profiles_false = []
        for profile, score in matching_profiles:
            if score[idx]:
                profiles_true.append((profile, score))
            else:
                profiles_false.append((profile, score))

        if profiles_true:
            matching_profiles = profiles_true
        else:
            matching_profiles = profiles_false

        if len(matching_profiles) == 1:
            return matching_profiles[0][0]

    return matching_profiles[0][0]