code: def lookup_language(languages, ranges):
      
  
      for language_range in ranges:
          while True:
              try:
                  return next(iter(basic_filter_languages(
                      languages,
                      [language_range])))
              except StopIteration:
                  pass
  
              try:
                  language_range = language_range.strip_rightmost()
              except ValueError:
                  break
docs: Look up a single language in the sequence `languages` using the lookup
      mechansim described in RFC4647. If no match is found, :data:`None` is
      returned. Otherwise, the first matching language is returned.
  
      `languages` must be a sequence of :class:`LanguageTag` objects, while
      `ranges` must be an iterable of :class:`LanguageRange` objects.