private <V> V callAndIgnoreTransientError(Callable<V> action) throws Exception {
    for (;;) {
      try {
        return action.call();
      } catch (KeeperException e) {
        switch (e.code()) {
          case CONNECTIONLOSS:
          case SESSIONEXPIRED:
          case OPERATIONTIMEOUT:
            LOG.warn("Possibly transient ZooKeeper exception", e);
            Threads.sleep(100);
            break;
          default:
            throw e;
        }
      }
    }
  }
Create a bunch of znodes in a hierarchy, try deleting one that has childs (it will fail), then
delete it recursively, then delete the last znode
hbase-zookeeper/src/test/java/org/apache/hadoop/hbase/zookeeper/TestZKUtil.java