Here is my implementation. This is possibly not the greatest practice in a running system, but it is very handy when debugging (if you need to clean up all state before starting again).
void deleteRecursively(String path, int version) throws KeeperException, InterruptedException {
for (String child : zk.getChildren(path, false)) {
deleteRecursively(path.replaceAll("/?$", "/") + child);
}
zk.delete(path, version);
}
Logged In: YES
user_id=12853
Originator: NO
Moved to Apache https://issues.apache.org/jira/browse/ZOOKEEPER-31