private static ASTNode findNextLeafElementAt(@NotNull ASTNode scopeNode, @Nullable ASTNode last, int offset) {
    int offsetR = offset;
    if (last != null) {
      offsetR -= last.getStartOffset() - scopeNode.getStartOffset() + last.getTextLength();
      while (offsetR >= 0) {
        ASTNode next = last.getTreeNext();
        if (next == null) {
          last = last.getTreeParent();
          continue;
        }
        int length = next.getTextLength();
        offsetR -= length;
        last = next;
      }
      scopeNode = last;
      offsetR += scopeNode.getTextLength();
    }
    return scopeNode.findLeafElementAt(offsetR);
  }
private static ASTNode findNextLeafElementAt(@NotNull ASTNode scopeNode, @Nullable ASTNode last, int offset)