Python Tree Implementation