def __rm_dir(callback, path, rm_dir=False, rm_root=False):
        "Remove directory at path, respecting the flags."
        for root, dirs, files in os.walk(path, False):
            # Ignore path if rm_root is false.
            if rm_root or root != path:
                callback()
                for name in files:
                    file_name = os.path.join(root, name)
                    # Remove file while catching errors.
                    try:
                        os.remove(file_name)
                    except OSError:
                        pass
                # Ignore directory if rm_dir is false.
                if rm_dir:
                    try:
                        os.rmdir(root)
                    except OSError:
                        pass
Remove directory at path, respecting the flags.
recipes/Python/577632_Directory_Pruner_1/recipe-577632.py