Это простая рекурсия:
def bt(h, n=1):
if h > 0:
return n, bt(h-1, 2*n), bt(h-1, 3*n)
>>> bt(1)
(1, None, None)
>>> bt(2)
(1, (2, None, None), (3, None, None))
>>> bt(3)
(1, (2, (4, None, None), (6, None, None)), (3, (6, None, None), (9, None, None)))