boolean (@Nullable Object object) { if (object == null) return false; VirtualFile ancestor = extractFileFromValue(); if (ancestor == null) return true; // always search in unknown nodes if (!ancestor.isValid()) return false; // do not search in invalid files if (object instanceof PsiElement) { object = PsiUtilCore.getVirtualFile((PsiElement)object); } if (object instanceof VirtualFile file) { if (!file.isValid()) return false; // do not search for invalid files return VfsUtilCore.isAncestor(ancestor, file, false); } return true; // any custom object can be contained somewhere in a tree }