PsiElementRef<Child> (@NotNull PsiElementRef<? extends Parent> parentRef) { final Parent parent = parentRef.getPsiElement(); if (parent != null) { final Child existing = findLinkedChild(parent); if (existing != null) { return PsiElementRef.real(existing); } } return PsiElementRef.imaginary(parentRef, this); }