void (PsiElement element, boolean requestFocus) { while (true) { if (element instanceof PsiFile || element instanceof PsiDirectory) { break; } if (element instanceof PsiClass && element.getParent() instanceof PsiFile) { break; } element = element.getParent(); } if (element instanceof PsiJavaFile) { final PsiClass[] classes = ((PsiJavaFile)element).getClasses(); if (classes.length > 0) { element = classes[0]; } } final PsiElement _element = element.getOriginalElement(); selectElementInCommander( () -> Commander.getInstance(myProject).selectElementInLeftPanel(_element, PsiUtilBase.getVirtualFile(_element)), requestFocus); }