def getwidth(tree): if tree.tb == None and tree.fb == None: return 1 return getwidth(tree.tb) + getwidth(tree.fb)