Model/Config.php
private function extractMapping($mapping, $countryCode)
    {
        $final = null;
        $extractMapping = json_decode($mapping, true);
        if (!$extractMapping) {
            try {
                $extractMapping = unserialize($mapping); // @codingStandardsIgnoreLine
            } catch (\Exception $e) {
                $extractMapping = [];
            }
        }

        if (is_array($extractMapping)) {
            $countryId = 'country_id';
            $key = 'store_id';
            // check for direct match
            foreach ($extractMapping as $map) {
                if (is_array($map) &&
                    isset($map[$countryId]) &&
                    strtolower(str_replace(' ', '', $map[$countryId])) == strtolower($countryCode)) {
                    if (isset($map[$key])) {
                        return (int)$map[$key];
                    }
                } elseif (is_array($map) &&
                    isset($map[$countryId]) &&
                    $map[$countryId] == '*' &&
                    isset($map[$key]) &&
                    $final === null) {
                    // check for wildcard
                    $final = (int)$map[$key];
                }
            }
        }
        return $final;
    }
private function extractMapping($mapping, $countryCode)
    {
        $final = null;
        $extractMapping = json_decode($mapping, true);
        if (!$extractMapping) {
            try {
                $extractMapping = unserialize($mapping); // @codingStandardsIgnoreLine
            } catch (\Exception $e) {
                $extractMapping = [];
            }
        }

        if (is_array($extractMapping)) {
            $countryId = 'country_id';
            $key = 'store_id';
            // check for direct match
            foreach ($extractMapping as $map) {
                if (is_array($map) &&
                    isset($map[$countryId]) &&
                    strtolower(str_replace(' ', '', $map[$countryId])) == strtolower($countryCode)) {
                    if (isset($map[$key])) {
                        return (int)$map[$key];
                    }
                } elseif (is_array($map) &&
                    isset($map[$countryId]) &&
                    $map[$countryId] == '*' &&
                    isset($map[$key]) &&
                    $final === null) {
                    // check for wildcard
                    $final = (int)$map[$key];
                }
            }
        }
        return $final;
    }
Filter country code mapping by priority

@param $mapping
@param $countryCode
@return int|null