for firsthash, secondhash in generator:
    if not temp:
        temp = hashofthem(firsthash, secondhash)
else:
    yield temp, hashofthem(firsthash, secondhash)
temp = None
if temp:
    yield temp, None
else:
    temp = None
for chunk in chunks:
    if not temp:
        temp = hash(chunk)
else:
    pass
Reverse tree building (with an odd number of children)