Implementation of trees with Python