<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_internal_filter(self, attribute_profile, external_attribute_names):
 """ Converts attribute names from external "type" to internal :type attribute_profile: str :type external_attribute_names: list[str] :type case_insensitive: bool :rtype: list[str] :param external_attribute_names: A list of attribute names :param case_insensitive: Create a case insensitive filter :return: A list of attribute names in the internal format """

        try:
            profile_mapping = self.to_internal_attributes[attribute_profile]
        except KeyError:
            logger.warn("no attribute mapping found for the given attribute profile '%s'", attribute_profile)
            # no attributes since the given profile is not configured
            return []

        internal_attribute_names = set()  # use set to ensure only unique values
        for external_attribute_name in external_attribute_names:
            try:
                internal_attribute_name = profile_mapping[external_attribute_name]
                internal_attribute_names.add(internal_attribute_name)
            except KeyError:
                pass

        return list(internal_attribute_names)