<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def stream_filesystem_node(path, recursive=False, patterns='**', chunk_size=default_chunk_size):
 """Gets a buffered generator for streaming either files or directories. Returns a buffered generator which encodes the file or directory at the given path as :mimetype:`multipart/form-data` with the corresponding headers. Parameters path : str The filepath of the directory or file to stream recursive : bool Stream all content within the directory recursively? patterns : str | list Single *glob* pattern or list of *glob* patterns and compiled regular expressions to match the names of the filepaths to keep chunk_size : int Maximum size of each stream chunk """

    is_dir = isinstance(path, six.string_types) and os.path.isdir(path)
    if recursive or is_dir:
        return stream_directory(path, recursive, patterns, chunk_size)
    else:
        return stream_files(path, chunk_size)