code: def _get_modpkg_path(dotted_name, pathlist=None):
      
      # split off top-most name
      parts = dotted_name.split('.', 1)
  
      if len(parts) > 1:
          # we have a dotted path, import top-level package
          try:
              file, pathname, description = imp.find_module(parts[0], pathlist)
              if file: file.close()
          except ImportError:
              return None
  
          # check if it's indeed a package
          if description[2] == imp.PKG_DIRECTORY:
              # recursively handle the remaining name parts
              pathname = _get_modpkg_path(parts[1], [pathname])
          else:
              pathname = None
      else:
          # plain name
          try:
              file, pathname, description = imp.find_module(
                  dotted_name, pathlist)
              if file:
                  file.close()
              if description[2] not in [imp.PY_SOURCE, imp.PKG_DIRECTORY]:
                  pathname = None
          except ImportError:
              pathname = None
  
      return pathname
docs: Get the filesystem path for a module or a package.
  
      Return the file system path to a file for a module, and to a directory for
      a package. Return None if the name is not found, or is a builtin or
      extension module.