def METHOD_NAME(affected_elem):
    constraints = []
    for pkg in affected_elem:
        name = pkg.attrib.get("name")
        if not name:
            continue
        pkg_ns, _, pkg_name = name.rpartition("/")
        purl = PackageURL(type="ebuild", name=pkg_name, namespace=pkg_ns)
        safe_versions, affected_versions = GentooImporter.get_safe_and_affected_versions(pkg)
        for version in safe_versions:
            constraints.append(
                VersionConstraint(version=GentooVersion(version), comparator="=").invert()
            )
        for version in affected_versions:
            constraints.append(
                VersionConstraint(version=GentooVersion(version), comparator="=")
            )
        if not constraints:
            continue
        yield AffectedPackage(
            package=purl, affected_version_range=EbuildVersionRange(constraints=constraints)
        )