code: private function collectDependencies(Pool $pool, array $collected, PackageInterface $package)
      {
          $requires = array_merge(
              $package->getRequires(),
              $package->getDevRequires()
          );
  
          foreach ($requires as $requireLink) {
              $requiredPackage = $this->lookupInstalledPackage($pool, $requireLink);
              if ($requiredPackage && !isset($collected[$requiredPackage->getName()])) {
                  $collected[$requiredPackage->getName()] = $requiredPackage;
                  $collected = $this->collectDependencies($pool, $collected, $requiredPackage);
              }
          }
  
          return $collected;
      }
docs: Recursively generates a map of package names to packages for all deps
  
  @param Pool             $pool      Package pool of installed packages
  @param array            $collected Current state of the map for recursion
  @param PackageInterface $package   The package to analyze
  
  @return array Map of package names to packages