Refactoring: extract make leaf function

Spreading the knowledge about how to assemble a leaf node is a bad thing
and would make changing things harder in the future.