def getdepth(tree): if tree.tb == None and tree.fb == None: return 0 return max(getdepth(tree.tb), getdepth(tree.fb)) + 1