public function collectPatches(RootPackageInterface $rootPackage, array $subPackages)
    {
        $collectedPatches = $this->collectPatchesFromPackage($rootPackage);
        $extra = $rootPackage->getExtra();
        if (isset($extra['allow-subpatches'])) {
            $allowedSubpatches = $extra['allow-subpatches'];
            if (!is_bool($allowedSubpatches) && !is_array($allowedSubpatches)) {
                $this->handleException(new Exception\InvalidPackageConfigurationValue($rootPackage, 'extra.allow-subpatches', $allowedSubpatches, 'The extra.allow-subpatches must be a boolean or an array of strings.'));
            }
            $collectedPatches->merge($this->collectSubpackagePatches($subPackages, $allowedSubpatches));
        }

        return $collectedPatches;
    }