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