diff --git a/cyclonedx/model/bom.py b/cyclonedx/model/bom.py index 7cb0081e..dec1d96a 100644 --- a/cyclonedx/model/bom.py +++ b/cyclonedx/model/bom.py @@ -708,9 +708,10 @@ def get_component_by_purl(self, purl: Optional['PackageURL']) -> Optional[Compon .. deprecated:: next """ if purl: - found = [x for x in self.components if x.purl == purl] - if len(found) == 1: - return found[0] + gen = (x for x in self.components if x.purl == purl) + first = next(gen, None) + if first and next(gen, None) is None: + return first return None