private ActionProcessingResults ProcessPickupsIteration(SystemWideValues systemWideValues, IReadOnlyDictionary <LeagueYear, IReadOnlyList <PickupBid> > allActiveBids,
                                                            ActionProcessingResults existingResults, Instant processingTime, IReadOnlyDictionary <Guid, MasterGameYear> masterGameYearDictionary)
    {
        IEnumerable <PickupBid> flatAllBids = allActiveBids.SelectMany(x => x.Value);

        var publisherStateSet = existingResults.PublisherStateSet;
        var processedBids     = new ProcessedBidSet();

        foreach (var leagueYear in allActiveBids)
        {
            if (!leagueYear.Value.Any())
            {
                continue;
            }

            var processedBidsForLeagueYear = ProcessPickupsForLeagueYear(leagueYear.Key, leagueYear.Value, publisherStateSet, systemWideValues, processingTime);
            processedBids = processedBids.AppendSet(processedBidsForLeagueYear);
        }

        ActionProcessingResults bidResults = GetBidProcessingResults(processedBids.SuccessBids, processedBids.FailedBids, publisherStateSet, processingTime, masterGameYearDictionary);
        var newResults    = existingResults.Combine(bidResults);
        var remainingBids = flatAllBids.Except(processedBids.ProcessedBids);

        if (remainingBids.Any())
        {
            IReadOnlyDictionary <LeagueYear, IReadOnlyList <PickupBid> > remainingBidDictionary = remainingBids.GroupToDictionary(x => x.LeagueYear);
            var subProcessingResults = ProcessPickupsIteration(systemWideValues, remainingBidDictionary, newResults, processingTime, masterGameYearDictionary);
            ActionProcessingResults combinedResults = newResults.Combine(subProcessingResults);
            return(combinedResults);
        }

        return(newResults);
    }
        public BidProcessingResults ProcessPickupsIteration(SystemWideValues systemWideValues, IReadOnlyDictionary <LeagueYear, IReadOnlyList <PickupBid> > allActiveBids,
                                                            IEnumerable <Publisher> currentPublisherStates, IClock clock, IEnumerable <SupportedYear> supportedYears)
        {
            if (!allActiveBids.Any())
            {
                return(new BidProcessingResults(new List <PickupBid>(), new List <PickupBid>(), new List <LeagueAction>(), currentPublisherStates, new List <PublisherGame>()));
            }

            IEnumerable <PickupBid> flatAllBids = allActiveBids.SelectMany(x => x.Value);

            var processedBids = new ProcessedBidSet();

            foreach (var leagueYear in allActiveBids)
            {
                if (!leagueYear.Value.Any())
                {
                    continue;
                }

                var processedBidsForLeagueYear = ProcessPickupsForLeagueYear(leagueYear.Key, leagueYear.Value, currentPublisherStates, systemWideValues, supportedYears);
                processedBids = processedBids.AppendSet(processedBidsForLeagueYear);
            }

            BidProcessingResults bidProcessingResults = GetProcessingResults(processedBids.SuccessBids, processedBids.FailedBids, currentPublisherStates, clock);

            var remainingBids = flatAllBids.Except(processedBids.ProcessedBids);

            if (remainingBids.Any())
            {
                Dictionary <LeagueYear, IReadOnlyList <PickupBid> > remainingBidDictionary = remainingBids.GroupBy(x => x.LeagueYear).ToDictionary(x => x.Key, y => (IReadOnlyList <PickupBid>)y.ToList());
                var subProcessingResults             = ProcessPickupsIteration(systemWideValues, remainingBidDictionary, bidProcessingResults.UpdatedPublishers, clock, supportedYears);
                BidProcessingResults combinedResults = bidProcessingResults.Combine(subProcessingResults);
                return(combinedResults);
            }

            return(bidProcessingResults);
        }