private void deleteDirectoryIfEmpty(boolean dryRun, Path path) throws IOException, TerseException {
        if (!Files.exists(path)) {
            return;
        }
        if (!Files.isWritable(path)) {
            throw new TerseException(path + " is not writable");
        }
        try (Stream<Path> list = Files.list(path)) {
            if (list.findAny().isPresent()) {
                return;
            }
        }
        log.debug("Delete {}", path);
        if (!dryRun) {
            Files.delete(path);
        }
    }
Rewrite multiple manifest files contained inside a class hierarchy.
Will create the files and parent directories if they do not exist and at least one element is specified.
Will delete the files and parent directories if they exist and would otherwise remain empty.

@param dryRun           True if the rewrite should be applied, false if it should be simulated.
@param pluginLocation   Path to top-level of the class hierarchy
@param manifestElements Map from plugin type to Class names of plugins which should appear in that manifest
tools/src/main/java/org/apache/kafka/tools/ManifestWorkspace.java