Implemented prepare_tree().