boolean (final Object element) { if (super.canRepresent(element)) return true; final PackageElement value = getValue(); if (value == null) return true; if (element instanceof PackageElement packageElement) { final String otherPackage = packageElement.getPackage().getQualifiedName(); final String aPackage = value.getPackage().getQualifiedName(); if (otherPackage.equals(aPackage)) { return true; } } if (element instanceof PsiDirectory directory) { return isPackageUnderDirectory(value, directory.getVirtualFile()); } if (element instanceof VirtualFile file) { return file.isDirectory() && isPackageUnderDirectory(value, file); } return false; }