This implementation is vulnerable to a forgery attack as a second pre-image attack, see these[1][2] crypto.stackexchange questions for an explanation. To avoid this vulnerability, you should pre-hash your leaves using a different hash function than the function provided such that H(x) != H'(x).
Do I have to add data to the leaf data or do I have to use a different hash for the leafs?
Based on the note that you describe
Do I have to add data to the leaf data or do I have to use a different hash for the leafs?
Regards