private @Nullable VirtualFileSystemEntry findInPersistence(@NotNull String name,
                                                             boolean ensureCanonicalName,
                                                             @NotNull NewVirtualFileSystem fs,
                                                             boolean isCaseSensitive) {
    VirtualFileSystemEntry child;
    synchronized (myData) {
      // maybe another doFindChild() sneaked in the middle
      child = doFindChildInArray(name, isCaseSensitive);
      if (child != null) return child; // including NULL_VIRTUAL_FILE
      if (allChildrenLoaded()) {
        return null;//all children loaded, but child not found -> not exist
      }

      // do not extract getId outside the synchronized block since it will cause a concurrency problem.
      PersistentFS pfs = owningPersistentFS();
      ChildInfo childInfo = pfs.findChildInfo(this, name, fs);
      if (childInfo == null) {
        myData.addAdoptedName(name, isCaseSensitive);
        return null;
      }

      if (ensureCanonicalName) {
        CharSequence persistedName = childInfo.getName();
        if (!Comparing.equal(name, persistedName)) {
          name = persistedName.toString();
          child = doFindChildInArray(name, isCaseSensitive);
          if (child != null) return child;
        }
      }

      int nameId = childInfo.getNameId(); // the name can change if file record was created
      int id = childInfo.getId();
      int attributes = pfs.getFileAttributes(id);
      //TODO RC: check isDeleted(attributes) before .mayHaveChildren() call,
      //         otherwise 'already deleted' exception is thrown sometimes (EA-933381)?
      boolean isEmptyDirectory = PersistentFS.isDirectory(attributes) && !pfs.mayHaveChildren(id);

      child = createChildImpl(id, nameId, attributes, isEmptyDirectory);

      addChild(child);
    }

    if (!child.isDirectory()) {
      // access check should only be called when a child is actually added to the parent, otherwise it may break VFP validity
      //noinspection TestOnlyProblems
      VfsRootAccess.assertAccessInTests(child, getFileSystem());
    }

    return child;
  }
private @Nullable VirtualFileSystemEntry findInPersistence(@NotNull String name,
                                                             boolean ensureCanonicalName,
                                                             @NotNull NewVirtualFileSystem fs,
                                                             boolean isCaseSensitive)