Object (@NotNull Object element) { if (element instanceof GroupingElement || element instanceof SimpleMessageElement) { return myRoot; } if (element instanceof NavigatableMessageElement) { GroupingElement result = ((NavigatableMessageElement)element).getParent(); return result == null ? myRoot : result; } return null; }