Binary trees traversing in python