public function upcast(SerializedEvent $event, UpcastingContext $context)
    {
        $result = [];
        $events = [$event];

        foreach ($this->upcasters as $upcaster) {
            $result = [];

            foreach ($events as $event) {
                if ($upcaster->supports($event)) {
                    $upcasted = $upcaster->upcast($event, $context);

                    // TODO: remove support of non array values by upcasters in next major release
                    if (!is_array($upcasted)) {
                        @trigger_error(
                            'Upcasters need to return an array collection of upcasted events, ' .
                            'non array return values are deprecated and support will be removed in the next major release',
                            E_USER_DEPRECATED
                        );

                        $upcasted = [$upcasted];
                    }

                    array_push($result, ...$upcasted);
                }
            }

            $events = $result;
        }

        return $result;
    }