def find_files(root_dir, patt, max_depth=1):
    """Finds all files in the given root directory whose filename matches the
    given glob pattern(s).

    Both ``root_dir`` and ``patt`` may contain glob patterns.

    Exammples::

        import fiftyone.core.utils as fou

        # Find .txt files in `/tmp`
        fou.find_files("/tmp", "*.txt")

        # Find .txt files in subdirectories of `/tmp` that begin with `foo-`
        fou.find_files("/tmp/foo-*", "*.txt")

        # Find .txt files in `/tmp` or its subdirectories
        fou.find_files("/tmp", "*.txt", max_depth=2)

    Args:
        root_dir: the root directory
        patt: a glob pattern or list of patterns
        max_depth (1): a maximum depth to search. 1 means ``root_dir`` only,
            2 means ``root_dir`` and its immediate subdirectories, etc

    Returns:
        a list of matching paths
    """
    if etau.is_str(patt):
        patt = [patt]

    paths = []
    for i in range(max_depth):
        root = os.path.join(root_dir, *list("*" * i))
        for p in patt:
            paths += glob.glob(os.path.join(root, p))

    return paths
Finds all files in the given root directory whose filename matches the
    given glob pattern(s).

    Both ``root_dir`` and ``patt`` may contain glob patterns.

    Exammples::

        import fiftyone.core.utils as fou

        # Find .txt files in `/tmp`
        fou.find_files("/tmp", "*.txt")

        # Find .txt files in subdirectories of `/tmp` that begin with `foo-`
        fou.find_files("/tmp/foo-*", "*.txt")

        # Find .txt files in `/tmp` or its subdirectories
        fou.find_files("/tmp", "*.txt", max_depth=2)

    Args:
        root_dir: the root directory
        patt: a glob pattern or list of patterns
        max_depth (1): a maximum depth to search. 1 means ``root_dir`` only,
            2 means ``root_dir`` and its immediate subdirectories, etc

    Returns:
        a list of matching paths
    
fiftyone/core/utils.py