In org-imenu-get-tree,
(when (<= level n)
(looking-at org-complex-heading-regexp)
(setq head (org-link-display-format
(org-match-string-no-properties 4))
m (org-imenu-new-marker))
should probably be
(when (and (<= level n)
(looking-at org-complex-heading-regexp))
(setq head (org-link-display-format
(org-match-string-no-properties 4))
m (org-imenu-new-marker))
...
i had an headling which (accidentally) consisted of just a todo keyword, making (org-match-string-no-properties 4) nil.