/**
  * @param object|null $relatedEntity
  * @param string|null $query
  * @param Organization|null $organization
  * @param int $limit
  *
  * @return array
  */
 public function getEmailRecipients($relatedEntity = null, $query = null, Organization $organization = null, $limit = 100)
 {
     $emails = [];
     foreach ($this->providers as $provider) {
         if ($limit <= 0) {
             break;
         }
         $args = new EmailRecipientsProviderArgs($relatedEntity, $query, $limit, array_reduce($emails, 'array_merge', []), $organization);
         $recipients = $provider->getRecipients($args);
         if (!$recipients) {
             continue;
         }
         $limit = max([0, $limit - count($recipients)]);
         if (!array_key_exists($provider->getSection(), $emails)) {
             $emails[$provider->getSection()] = [];
         }
         $emails[$provider->getSection()] = array_merge($emails[$provider->getSection()], $recipients);
     }
     $result = [];
     foreach ($emails as $section => $sectionEmails) {
         $items = array_map(function (Recipient $recipient) {
             return $this->emailRecipientsHelper->createRecipientData($recipient);
         }, $sectionEmails);
         $result[] = ['text' => $this->translator->trans($section), 'children' => array_values($items)];
     }
     return $result;
 }