No margin for consecutive headings in Reading Mode

TL;DR I’m trying to achieve what this css does in Reading Mode, that is if a heading immediatly follows another I want both of them to have no margin applied to them.

h1 + h2 {
	margin-top: 0 !important;
}
h1:has(+h2) {
	margin-bottom: 0 !important;
	margin-block-end: 0 !important;
}

So far I’ve looked at using css, which seems impossible since in RM headings are wrapped in divs which makes the approach above not work.
I’ve also looked into using a MarkdownPostProcessor in a Plugin, but that way I don’t seem to be able to find a way to access the next sibling element, since I only get the ones that were rendered individually.
So my questions is: Is there a way to access (the next) sibling/s in a PostProcessor or would I have to listen for changes in a document and traverse the whole document to achieve this?