Recursive version of GLOB. Builds the glob of files while
    also searching in the subdirectories of the given roots. An
    optional set of exclusion patterns will filter out the
    matching entries from the result. The exclusions also apply
    to the subdirectory scanning, such that directories that
    match the exclusion patterns will not be searched.

def glob_tree(roots, patterns, exclude_patterns=None):
    """Recursive version of GLOB. Builds the glob of files while
    also searching in the subdirectories of the given roots. An
    optional set of exclusion patterns will filter out the
    matching entries from the result. The exclusions also apply
    to the subdirectory scanning, such that directories that
    match the exclusion patterns will not be searched."""

    if not exclude_patterns:
        exclude_patterns = []

    result = glob(roots, patterns, exclude_patterns)
    subdirs = [s for s in glob(roots, ["*"], exclude_patterns) if s != "." and s != ".." and os.path.isdir(s)]
    if subdirs:
        result.extend(glob_tree(subdirs, patterns, exclude_patterns))

    return result