code: public static boolean deleteAtomic(ZooKeeperClient zk, String path, String expectedValue)
      {
          final Stat stat = new Stat();
          String value = getWithStat(zk, path, stat);
          if (!expectedValue.equals(value)) {
              return false;
          }
          try {
              zk.get().delete(path, stat.getVersion());
              return true;
          } catch (Exception e) {
              LOG.error("Failed to delete path "+path+" with expected value '"+expectedValue+"'", e);
          }
          return false;
      }
docs: Attempts to atomically delete the ZNode with the specified path and value. Should be preferred over calling
  delete() if the value is known.
  
  @param zk ZooKeeper client.
  @param path Path to be deleted.
  @param expectedValue The expected value of the ZNode at the specified path.
  @return True if the path was deleted, false otherwise.