def check_for_duplicate_packages(self, packages_yml):
        """Loop through contents of `packages.yml` to ensure no duplicate package names + versions.

        This duplicate check will take into consideration exact match of a package name, as well as
        a check to see if a package name exists within a name (i.e. a package name inside a git URL).

        Args:
            packages_yml (dict): In-memory read of `packages.yml` contents

        Returns:
            dict: Updated or untouched packages_yml contents
        """
        for i, pkg_entry in enumerate(packages_yml["packages"]):
            for val in pkg_entry.values():
                if self.args.add_package["name"] in val:
                    del packages_yml["packages"][i]

                    fire_event(DepsFoundDuplicatePackage(removed_package=pkg_entry))

        return packages_yml
Loop through contents of `packages.yml` to ensure no duplicate package names + versions.

        This duplicate check will take into consideration exact match of a package name, as well as
        a check to see if a package name exists within a name (i.e. a package name inside a git URL).

        Args:
            packages_yml (dict): In-memory read of `packages.yml` contents

        Returns:
            dict: Updated or untouched packages_yml contents
        
core/dbt/task/deps.py