code: def remove_nested_packages(packages: List[str]) -> List[str]:
      """Remove nested packages from a list of packages.
  
      >>> remove_nested_packages(["a", "a.b1", "a.b2", "a.b1.c1"])
      ['a']
      >>> remove_nested_packages(["a", "b", "c.d", "c.d.e.f", "g.h", "a.a1"])
      ['a', 'b', 'c.d', 'g.h']
      """
      pkgs = sorted(packages, key=len)
      top_level = pkgs[:]
      size = len(pkgs)
      for i, name in enumerate(reversed(pkgs)):
          if any(name.startswith(f"{other}.") for other in top_level):
              top_level.pop(size - i - 1)
  
      return top_level
  
imports: import itertools
  import os
  from fnmatch import fnmatchcase
  from glob import glob
  from pathlib import Path
  from typing import TYPE_CHECKING, Dict, Iterable, Iterator, List, Mapping, Optional, Tuple, Union
  import _distutils_hack.override
  from distutils import log
  from distutils.util import convert_path
label_desc: Use image node_id 3 for calling a global function with example usage: remove_nested_packages(packages) and returns: top_level