docs: private static Tree getNextNodeOrParent(Tree current, VisitorState state) {
      Tree predecessorNode = current;
      TreePath enclosingPath = state.getPath();
      while (enclosingPath != null
          && !(enclosingPath.getLeaf() instanceof BlockTree)
          && !(enclosingPath.getLeaf() instanceof ClassTree)) {
        predecessorNode = enclosingPath.getLeaf();
        enclosingPath = enclosingPath.getParentPath();
      }
  
      if (enclosingPath == null) {
        return state.getPath().getParentPath().getLeaf();
      }
  
      Tree parent = enclosingPath.getLeaf();
  
      if (parent instanceof BlockTree) {
        return after(predecessorNode, ((BlockTree) parent).getStatements(), parent);
      } else if (parent instanceof ClassTree) {
        return after(predecessorNode, ((ClassTree) parent).getMembers(), parent);
      }
      return parent;
    }