Don't overwrite unless existing entry is subheader

Should fix #3083
(cherry picked from commit 6c93b1656a61df02612a2616cbcdbe6845417d67)