<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def rglob(dirname, pattern, dirs=False, sort=True):

 """recursive glob, gets all files that match the pattern within the directory tree"""

    fns = []
    path = str(dirname)
    if os.path.isdir(path):
        fns = glob(os.path.join(escape(path), pattern))
        dns = [fn for fn 
                in [os.path.join(path, fn)
                    for fn in os.listdir(path)] 
                if os.path.isdir(fn)]
        if dirs==True:
            fns += dns
        for d in dns:
            fns += rglob(d, pattern)
        if sort==True:
            fns.sort()
    else:
        log.warn("not a directory: %r" % path)
    return fns