public static function unpackDeferredResults($result)
    {
        while ($result instanceof DeferredResult) {
            $result = $result->result;
        }

        if (is_array($result)) {
            foreach ($result as $key => $value) {
                $result[$key] = static::unpackDeferredResults($value);
            }
        }

        return $result;
    }