add flatten_tree.cpp