code: public static void deleteChildren(ZooKeeper zookeeper, String path, boolean deleteSelf) throws InterruptedException, KeeperException
      {
          PathUtils.validatePath(path);
  
          List<String> children = zookeeper.getChildren(path, null);
          for ( String child : children )
          {
              String fullPath = makePath(path, child);
              deleteChildren(zookeeper, fullPath, true);
          }
  
          if ( deleteSelf )
          {
              try
              {
                  zookeeper.delete(path, -1);
              }
              catch ( KeeperException.NotEmptyException e )
              {
                  //someone has created a new child since we checked ... delete again.
                  deleteChildren(zookeeper, path, true);
              }
              catch ( KeeperException.NoNodeException e )
              {
                  // ignore... someone else has deleted the node it since we checked
              }
          }
      }
docs: Recursively deletes children of a node.
  
  @param zookeeper  the client
  @param path       path of the node to delete
  @param deleteSelf flag that indicates that the node should also get deleted
  @throws InterruptedException
  @throws KeeperException