that is often true, especially with large buffers, but you have to add a bunch of code to go to point-max, and check the level with this.
#+BEGIN_SRC emacs-lisp
(save-excursion
(goto-char (point-max))
(let (components
(headings '()))
(while (re-search-backward org-complex-heading-regexp nil t)
(setq components (org-heading-components))
(when (= (first components) 1)
(push (fifth components) headings)))
headings))
#+END_SRC
This takes about 0.04 ms on a small example. The org-map-entries approach takes 0.6ms on the same example. In a big buffer that might be noticeable!
John
-----------------------------------
Professor John Kitchin (he/him/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803