flatten BT to linked list Python AC