human
Complete this python program:
def _check_directory(name, user, group, recurse, mode, clean, require, exclude_pat, max_depth=None, follow_symlinks=False):
assistant
#Here is the Python code you requested.

    """Check what changes need to be made on a directory
    """
    changes = {}
    if (recurse or clean):
        assert ((max_depth is None) or (not clean))
        walk_l = list(_depth_limited_walk(name, max_depth))
        walk_d = {}
        for i in walk_l:
            walk_d[i[0]] = (i[1], i[2])
    if recurse:
        try:
            recurse_set = _get_recurse_set(recurse)
        except (TypeError, ValueError) as exc:
            return (False, '{0}'.format(exc), changes)
        if ('user' not in recurse_set):
            user = None
        if ('group' not in recurse_set):
            group = None
        if ('mode' not in recurse_set):
            mode = None
        check_files = ('ignore_files' not in recurse_set)
        check_dirs = ('ignore_dirs' not in recurse_set)
        for (root, dirs, files) in walk_l:
            if check_files:
                for fname in files:
                    fchange = {}
                    path = os.path.join(root, fname)
                    stats = __salt__['file.stats'](path, None, follow_symlinks)
                    if ((user is not None) and (user != stats.get('user'))):
                        fchange['user'] = user
                    if ((group is not None) and (group != stats.get('group'))):
                        fchange['group'] = group
                    if fchange:
                        changes[path] = fchange
            if check_dirs:
                for name_ in dirs:
                    path = os.path.join(root, name_)
                    fchange = _check_dir_meta(path, user, group, mode, follow_symlinks)
                    if fchange:
                        changes[path] = fchange
    fchange = _check_dir_meta(name, user, group, mode, follow_symlinks)
    if fchange:
        changes[name] = fchange
    if clean:
        keep = _gen_keep_files(name, require, walk_d)
        def _check_changes(fname):
            path = os.path.join(root, fname)
            if (path in keep):
                return {}
            elif (not salt.utils.check_include_exclude(os.path.relpath(path, name), None,...