def METHOD_NAME(path: str) -> Generator[str, None, None]:
    """Given file or directory path, yield all valid sample config fpaths recursively.
    Arguments:
        path (str): The file or directory path to check
                    for valid samplegen config files.
                    Directories are checked recursively.
    Raises:
        types.InvalidConfig: If 'path' is an invalid sampleconfig file
                             or 'path' is not a file or directory.
    Returns:
        Generator[str, None, None]: All valid samplegen config files
                                    starting at 'path'.
    """
    # If a user passes in a directory to search for sample configs,
    # it is required to ignore any non-sample-config files so as to avoid
    # being unhelpfully strict.
    # Directly named files, however, should generate an error, because silently
    # ignoring them is less helpful than failing loudly.
    if os.path.isfile(path):
        if not path.endswith('.yaml'):
            raise types.InvalidConfig(f"Not a yaml file: {path}")
        with open(path) as f:
            if not any(is_valid_sample_cfg(doc)
                       for doc in yaml.safe_load_all(f.read())):
                raise types.InvalidConfig(
                    f"No valid sample config in file: {path}")
            yield path
    # Note: if we ever need to recursively check directories for sample configs,
    #       add an "elif os.path.isdir(path)" yielding from os.walk right here.
    else:
        raise types.InvalidConfig(f"No such file: {path}")