code: def get_module_part(dotted_name, context_file=None):
      
      # os.path trick
      if dotted_name.startswith("os.path"):
          return "os.path"
      parts = dotted_name.split(".")
      if context_file is not None:
          # first check for builtin module which won't be considered latter
          # in that case (path != None)
          if parts[0] in BUILTIN_MODULES:
              if len(parts) > 2:
                  raise ImportError(dotted_name)
              return parts[0]
          # don't use += or insert, we want a new list to be created !
      path = None
      starti = 0
      if parts[0] == "":
          assert (
              context_file is not None
          ), "explicit relative import, but no context_file?"
          path = []  # prevent resolving the import non-relatively
          starti = 1
      while parts[starti] == "":  # for all further dots: change context
          starti += 1
          context_file = os.path.dirname(context_file)
      for i in range(starti, len(parts)):
          try:
              file_from_modpath(
                  parts[starti : i + 1], path=path, context_file=context_file
              )
          except ImportError:
              if i < max(1, len(parts) - 2):
                  raise
              return ".".join(parts[:i])
      return dotted_name
docs: given a dotted name return the module part of the name :
  
      >>> get_module_part('astroid.as_string.dump')
      'astroid.as_string'
  
      :type dotted_name: str
      :param dotted_name: full name of the identifier we are interested in
  
      :type context_file: str or None
      :param context_file:
        context file to consider, necessary if the identifier has been
        introduced using a relative import unresolvable in the actual
        context (i.e. modutils)
  
  
      :raise ImportError: if there is no such module in the directory
  
      :rtype: str or None
      :return:
        the module part of the name or None if we have not been able at
        all to import the given name
  
      XXX: deprecated, since it doesn't handle package precedence over module
      (see #10066)