private function deserializeResult($operation, $type, $serializer, array $mappers)
    {
        $mappers = array_filter($mappers, function ($mapper) use ($type) {
            return $mapper['typeUrl'] === $type;
        });

        if (count($mappers) === 0) {
            throw new \RuntimeException(sprintf('No mapper exists for operation response type %s.', $type));
        }

        $mapper = current($mappers);
        $message = $mapper['message'];

        $response = new $message();
        $anyResponse = $operation->getLastProtoResponse()->getResponse();

        if (is_null($anyResponse)) {
            return null;
        }

        $response->mergeFromString($anyResponse->getValue());

        return $serializer->encodeMessage($response);
    }