PsiElement (int offset, PsiElement element) { if (offset < 0) { return null; } PsiElement candidate = element.getContainingFile(); while (candidate.getNode().getFirstChildNode() != null) { candidate = candidate.findElementAt(offset); } return candidate; }