Hello,
I don't have good elisp skills, but the following might give you an idea how to start:
(defun org-todo-recursive (element-at-point)
(interactive
(let (element-at-point)
(forward-char) ;to make sure you have item (no plain-list)
(setq element-at-point (org-element-at-point))
(list element-at-point)))
(if (eq 'headline (org-element-type element-at-point))
(progn ; then
(narrow-to-region
(org-element-property ':begin element-at-point)
(org-element-property ':end elemen-at-point))
(setq headline-content-list
(cdr (car (org-element-contents
(org-element-parse-buffer)))))
;; Need to use car, as 'contents' is between an extra pair of brackets
;; Now you got a list with org-elements of form
;; ((section (...))(headline (...))(headline (...)))
;; Perhaps run over them in a while loop, if type is headline, then (org-element-put-property current ':todo-keyword ...)
(while (not (eq <lenghth of list> 0))
((setq current (car (headline-content-list)))
(setq headline-content-list (cdr (headline-content-list)))
(if (eq 'headline (org-element-type current))
(let ((todo-keyword (org-element-property
':todo-keyword current)))
(<Change the property depending on current state>)
)
(message "Must be on heading")) ;else
Dieter