def METHOD_NAME(would_be_installed, package_set):
    # type: (Set[str], PackageSet) -> Set[str]
    packages_affected = set(would_be_installed)
    for package_name in package_set:
        if package_name in packages_affected:
            continue
        for req in package_set[package_name].requires:
            if canonicalize_name(req.name) in packages_affected:
                packages_affected.add(package_name)
                break
    return packages_affected