public function matchPackageVersionEntities($availableVersions, $wantedVersion)
    {
        if (empty($availableVersions)) {
            $result = null;
        } else {
            $keys = [];
            foreach ($availableVersions as $pv) {
                $keys[$pv->getVersion()] = $pv;
            }
            $bestKey = $this->matchPackageVersions(array_keys($keys), $wantedVersion);
            $result = $keys[$bestKey];
        }

        return $result;
    }