@Override
  public @Nullable Object getParentElement(@NotNull Object element) {
    if (element instanceof FileElement fileElement) {

      final VirtualFile elementFile = getValidFile(fileElement);
      VirtualFile rootElementFile = myRootElement.getFile();
      if (rootElementFile != null && rootElementFile.equals(elementFile)) {
        return null;
      }

      final VirtualFile parentElementFile = getValidFile(fileElement.getParent());

      if (elementFile != null && parentElementFile != null) {
        final VirtualFile parentFile = elementFile.getParent();
        if (parentElementFile.equals(parentFile)) return fileElement.getParent();
      }

      VirtualFile file = fileElement.getFile();
      if (file == null) return null;
      VirtualFile parent = file.getParent();
      if (parent != null && parent.getFileSystem() instanceof JarFileSystem && parent.getParent() == null) {
        // parent of jar contents should be local jar file
        String localPath = parent.getPath().substring(0, parent.getPath().length() - JarFileSystem.JAR_SEPARATOR.length());
        parent = LocalFileSystem.getInstance().findFileByPath(localPath);
      }
      if (parent == null || parent.isValid() && parent.equals(rootElementFile)) {
        return myRootElement;
      }

      return new FileElement(parent, parent.getName());
    }

    return null;
  }
@Override
  public @Nullable Object getParentElement(@NotNull Object element)