Return an optimized mapping of available providers

def _optimize_providers(self, providers):
        '''
        Return an optimized mapping of available providers
        '''
        new_providers = {}
        provider_by_driver = {}

        for alias, driver in six.iteritems(providers):
            for name, data in six.iteritems(driver):
                if name not in provider_by_driver:
                    provider_by_driver[name] = {}

                provider_by_driver[name][alias] = data

        for driver, providers_data in six.iteritems(provider_by_driver):
            fun = '{0}.optimize_providers'.format(driver)
            if fun not in self.clouds:
                log.debug('The \'%s\' cloud driver is unable to be optimized.', driver)

                for name, prov_data in six.iteritems(providers_data):
                    if name not in new_providers:
                        new_providers[name] = {}
                    new_providers[name][driver] = prov_data
                continue

            new_data = self.clouds[fun](providers_data)
            if new_data:
                for name, prov_data in six.iteritems(new_data):
                    if name not in new_providers:
                        new_providers[name] = {}
                    new_providers[name][driver] = prov_data

        return new_providers