code: public static void mkdirs(ZooKeeper zookeeper, String path, boolean makeLastNode, InternalACLProvider aclProvider, boolean asContainers) throws InterruptedException, KeeperException
      {
          PathUtils.validatePath(path);
  
          int pos = 1; // skip first slash, root is guaranteed to exist
          do
          {
              pos = path.indexOf(PATH_SEPARATOR, pos + 1);
  
              if ( pos == -1 )
              {
                  if ( makeLastNode )
                  {
                      pos = path.length();
                  }
                  else
                  {
                      break;
                  }
              }
  
              String subPath = path.substring(0, pos);
              if ( zookeeper.exists(subPath, false) == null )
              {
                  try
                  {
                      List<ACL> acl = null;
                      if ( aclProvider != null )
                      {
                          acl = aclProvider.getAclForPath(subPath);
                          if ( acl == null )
                          {
                              acl = aclProvider.getDefaultAcl();
                          }
                      }
                      if ( acl == null )
                      {
                          acl = ZooDefs.Ids.OPEN_ACL_UNSAFE;
                      }
                      zookeeper.create(subPath, new byte[0], acl, getCreateMode(asContainers));
                  }
                  catch ( KeeperException.NodeExistsException e )
                  {
                      // ignore... someone else has created it since we checked
                  }
              }
  
          }
          while ( pos < path.length() );
      }
docs: Make sure all the nodes in the path are created. NOTE: Unlike File.mkdirs(), Zookeeper doesn't distinguish
  between directories and files. So, every node in the path is created. The data for each node is an empty blob
  
  @param zookeeper    the client
  @param path         path to ensure
  @param makeLastNode if true, all nodes are created. If false, only the parent nodes are created
  @param aclProvider  if not null, the ACL provider to use when creating parent nodes
  @param asContainers if true, nodes are created as  CreateMode#CONTAINER
  @throws InterruptedException                 thread interruption
  @throws org.apache.zookeeper.KeeperException Zookeeper errors