Assuming that child_ids are unique, what about the following for this `if !defaults[:embed]` block:

```ruby
              child_ids_per_record = records.map{ |r| r.send(details[:ids_cache_name]) }
              all_child_ids = child_ids_per_record.flatten
              all_child_records = details[:association_class].fetch_multi(*all_child_ids)
              records.zip(child_ids_per_record).each_with_index do |record, child_ids|
                child_records = child_ids.map{ |i| all_child_records.shift }
                record.send(details[:prepopulate_method_name], child_records)
              end
```