I've added an extra button to the TinyMCE editor that simply puts this into the body:
<div class="foo">Hello world</div>
Clicking on the end of Hello world and pressing return duplicates the whole div, inside the div.
<div class="foo">Hello world<div class="foo">Hello world</div></div>
Half-solution
By configuring these two options below, the custom element is not duplicated anymore, but now the issue arises that you need to press shift + enter to jump out of any element (h1, address, p etc) which is not preferred in this scenario.
force_br_newlines: true,
forced_root_block: ''
How can I make TinyMCE stop repeating my custom element on return key while conserving the default on return key