code: def _GetTypeFromScope(self, package, type_name, scope):
      
      if type_name not in scope:
        components = _PrefixWithDot(package).split('.')
        while components:
          possible_match = '.'.join(components + [type_name])
          if possible_match in scope:
            type_name = possible_match
            break
          else:
            components.pop(-1)
      return scope[type_name]
docs: Finds a given type name in the current scope.
  
      Args:
        package: The package the proto should be located in.
        type_name: The name of the type to be found in the scope.
        scope: Dict mapping short and full symbols to message and enum types.
  
      Returns:
        The descriptor for the requested type.