def METHOD_NAME(ret, target, force):
    not_empty = os.listdir(target)
    if not not_empty:
        log.debug(
            "target %s found, but directory is empty, automatically deleting", target
        )
        shutil.rmtree(target)
    elif force:
        log.debug(
            "target %s found and is not empty. "
            "Since force option is in use, deleting anyway.",
            target,
        )
        shutil.rmtree(target)
    else:
        return _fail(ret, "Directory exists, and is not empty")