Object (PsiElement element) { // walk up the psi-tree until we find an element from the structure view while (element != null && !(element instanceof PsiFile) && !PRESENTABLE_TYPES.contains(PsiUtilCore.getElementType(element))) { IElementType parentType = PsiUtilCore.getElementType(element.getParent()); final PsiElement previous = element.getPrevSibling(); if (previous == null || !TRANSPARENT_CONTAINERS.contains(parentType)) { element = element.getParent(); } else { element = previous; } } return element; }