code: def GetMessages(self, files):
      # TODO(amauryfa): Fix the differences with MessageFactory.
      
  
      def _GetAllMessageNames(desc):
        """Walk a message Descriptor and recursively yields all message names."""
        yield desc.full_name
        for msg_desc in desc.nested_types:
          for full_name in _GetAllMessageNames(msg_desc):
            yield full_name
  
      result = {}
      for file_name in files:
        file_desc = self.pool.FindFileByName(file_name)
        for msg_desc in file_desc.message_types_by_name.values():
          for full_name in _GetAllMessageNames(msg_desc):
            try:
              result[full_name] = self._classes[full_name]
            except KeyError:
              # This descriptor has no registered class, skip it.
              pass
      return result
docs: Gets all registered messages from a specified file.
  
      Only messages already created and registered will be returned; (this is the
      case for imported _pb2 modules)
      But unlike MessageFactory, this version also returns already defined nested
      messages, but does not register any message extensions.
  
      Args:
        files: The file names to extract messages from.
  
      Returns:
        A dictionary mapping proto names to the message classes.
  
      Raises:
        KeyError: if a file could not be found.