PsiElement (@Nullable PsiElement element, @NotNull Editor editor, boolean down) { if (element == null) return null; int line = getElementLine(element, editor, down); PsiElement lastElement = element; while (true) { if (lastElement == null) return null; PsiElement sibling = firstNonWhiteSibling(lastElement, down); if (getElementLine(sibling, editor, down) == line) { lastElement = sibling; } else break; } return lastElement; }