code: def existingDirectory(string):
      """
      A custom type for the argparse commandline parser.
      Check whether the supplied string points to a valid directory.
  
      Examples
      --------
  
      >>> parser.add_argument('argname', type=existingDirectory, help='help')
      """
      if not os.path.isdir(string):
          argparse.ArgumentTypeError(
              "{} is not a valid directory.".format(string)
          )
      return string
  
imports: import argparse
  import itertools
  import os
label_desc: Use image node_id 1 for calling a global function with example usage: existingDirectory(string) and returns: string