def _list_subfolders(project, path, cached_folder_lists, recurse=True):
    if project not in cached_folder_lists:
        cached_folder_lists[project] = dxpy.get_handler(project).describe(
            input_params={'folders': True}
        )['folders']
    # TODO: support shell-style path globbing (i.e. /a*/c matches /ab/c but not /a/b/c)
    # return pathmatch.filter(cached_folder_lists[project], os.path.join(path, '*'))
    if recurse:
        return (f for f in cached_folder_lists[project] if f.startswith(path))
    else:
        return (f for f in cached_folder_lists[project] if f.startswith(path) and '/' not in f[len(path)+1:])
dataset/ETHPy150Open dnanexus/dx-toolkit/src/python/dxpy/cli/download.py/_list_subfolders/original