code: def search_typedef(stmt, name):
      
      mod = stmt.i_orig_module
      while stmt is not None:
          if name in stmt.i_typedefs:
              t = stmt.i_typedefs[name]
              if (mod is not None and
                  mod != t.i_orig_module and
                  t.i_orig_module.keyword == 'submodule'):
                  # make sure this submodule is included
                  if mod.search_one('include', t.i_orig_module.arg) is None:
                      return None
              return t
          stmt = stmt.parent
      return None
docs: Search for a typedef in scope
      First search the hierarchy, then the module and its submodules.