I am writing some code implementing taproot address creation where a script path is present and I have a quick question surrounding the reference code.
The BIP-341 reference method taproot_tree_helper(script_tree)
will recursively call itself if the parameter is not a tuple (leaf node). When it calls itself, it passes in it's child nodes by:
left, left_h = taproot_tree_helper(script_tree[0])
right, right_h = taproot_tree_helper(script_tree[1])
What should happen if a node only contains a single child (where script_tree[1] does not exist)? Should it pass in the same node twice for both left and right or should the tree be constructed in a way that this cannot happen?
Thanks