void doCheckConsistency(@Nullable VirtualFile parent, @NotNull String name, @NotNull String urlFromRoot) {
    VirtualFile myFile = myFile();

    if (!(this instanceof FilePartNodeRoot)) {
      if (myFile == null) {
        String myUrl = myUrl();
        String expectedUrl = StringUtil.trimEnd(urlFromRoot, '/');
        String actualUrl = StringUtil.trimEnd(myUrl, '/');
        assert FileUtil.namesEqual(actualUrl, expectedUrl) : "Expected url: '" + expectedUrl + "' but got: '" + actualUrl + "'; parent="+parent+"; name="+name+"; urlFromParent="+urlFromRoot;
      }
      else {
        assert Comparing.equal(getParentThroughJar(myFile, myFS), parent) :
          "parent: " + parent + "\n myFile: " + myFile + "\n getParentThroughJar(myFile, myFS): " + getParentThroughJar(myFile, myFS) +
          "\n myFS: " + myFS + "\n myFile.getParent(): " + myFile.getParent()+"\n this: "+this;
      }
    }
    assert !"..".equals(name) && !".".equals(name) : "url must not contain '.' or '..' but got: " + this;
    String prevChildName = "";
    Set<String> childNames = CollectionFactory.createFilePathSet(children.length, isCaseSensitive());
    for (int i = 0; i < children.length; i++) {
      FilePartNode child = children[i];
      String childName = child.getName().toString();
      boolean added = childNames.add(childName);
      assert added : "'" + childName + "' is already in the childNames set (" + childNames + "). isCaseSensitive()=" + isCaseSensitive() + ";\n all children=" + Arrays.toString(children);

      boolean needSeparator = !urlFromRoot.isEmpty() && !urlFromRoot.endsWith("/") && !childName.equals(JarFileSystem.JAR_SEPARATOR);
      String childUrlFromRoot = needSeparator ? urlFromRoot + "/" + childName : urlFromRoot + childName;
      if (child.myFS != myFS) {
        // "file:" changed to "jar:"
        childUrlFromRoot = child.myFS.getProtocol() + StringUtil.trimStart(childUrlFromRoot, myFS.getProtocol());
      }
      child.doCheckConsistency(myFile, childName, childUrlFromRoot);
      if (i != 0) {
        assert StringUtil.compare(prevChildName, childName, !isCaseSensitive()) < 0: "children[" + i + "] = " + child + "; [-1] = " + children[i - 1] +"; isCaseSensitive()="+isCaseSensitive();
      }
      // fs is allowed to change in one direction only: local->jar
      assert myFS instanceof LocalFileSystem && (child.myFS instanceof ArchiveFileSystem || child.myFS instanceof LocalFileSystem)
        || myFS instanceof ArchiveFileSystem && child.myFS instanceof ArchiveFileSystem
        : "this: "+this+"; fs="+myFS+"; child[" + i + "] = " + child + "; fs="+child.myFS;
      // child of UrlPartNode can be only UrlPartNode
      assert !(this instanceof UrlPartNode) || child instanceof UrlPartNode : "this: "+this+"; fs="+myFS+"; child[" + i + "] = " + child + "; fs="+child.myFS;
      prevChildName = childName;
    }
    int[] leafNumber = new int[1];
    processPointers(p -> { assert p.myNode == this; leafNumber[0]++; });
    int useCount = leafNumber[0];
    assert (useCount == 0) == (leaves == null) : useCount + " - " + (leaves instanceof VirtualFilePointerImpl ? leaves : Arrays.toString((VirtualFilePointerImpl[])leaves));

    if (myFileOrUrl instanceof String) {
      String myPath = VfsUtilCore.urlToPath(myUrl());
      String nameFromPath = nameId == JAR_SEPARATOR_NAME_ID || myPath.endsWith(JarFileSystem.JAR_SEPARATOR) ? JarFileSystem.JAR_SEPARATOR : PathUtil.getFileName(myPath);
      if (!myPath.isEmpty() && nameFromPath.isEmpty()) {
        nameFromPath = "/";
      }
      assert StringUtilRt.equal(nameFromPath, name, isCaseSensitive()) : "fileAndUrl: " + myFileOrUrl + "; but this: " + this + "; nameFromPath: " + nameFromPath + "; name: " + name + "; myPath: " + myPath + "; url: " + myUrl() + ";";
      if (myFile != null) {
        String fileName = myFile.getParent() == null && myFile.getFileSystem() instanceof ArchiveFileSystem ? JarFileSystem.JAR_SEPARATOR : myFile.getName();
        assert fileName.equals(name) : "fileAndUrl: " + myFileOrUrl + "; but this: " + this;
        assert myFile.getFileSystem() == myFS;
      }
    }
  }
void doCheckConsistency(@Nullable VirtualFile parent, @NotNull String name, @NotNull String urlFromRoot)