private int getFirstUppermostControlStructureKeywordOffset(@NotNull SemanticEditorPosition position) {
    SemanticEditorPosition curr = position.copy();
    while (!curr.isAtEnd()) {
      if (isStartOfStatementWithOptionalBlock(curr)) {
        SemanticEditorPosition candidate = curr.copy();
        curr.moveBefore();
        curr.moveBeforeOptionalMix(Whitespace, LineComment, BlockComment);
        if (curr.isAt(RightParenthesis)) {
          curr.moveBeforeParentheses(LeftParenthesis, RightParenthesis);
          SemanticEditorPosition controlStructureCheck = curr.copy();
          controlStructureCheck.moveBeforeOptionalMix(Whitespace, LineComment, BlockComment);
          if (isStartOfStatementWithOptionalBlock(controlStructureCheck)) {
            continue;
          }
        }
        return candidate.getStartOffset();
      }
      else if (curr.isAt(BlockClosingBrace)) {
        curr.moveBeforeParentheses(BlockOpeningBrace, BlockClosingBrace);
        continue;
      }
      curr.moveBefore();
    }
    return position.before().getStartOffset();
  }
private int getFirstUppermostControlStructureKeywordOffset(@NotNull SemanticEditorPosition position)