How can I test in elisp whether an
org-mode tree node (either a heading or a list item) is folded?
Looking at the code it seems the logic is a little complicated and only in
org-cycle-internal-local, with no public API?
I've sometimes wished for this when writing small functions to navigate the tree and change its folding state - e.g. today when attempting to answer this question.
Note that if the node has no children, for my purposes I'd either need that to be regarded as folded, or to be able to find out explicitly whether there are children. Otherwise I can't keep
org-cycleing until the node is folded.