flatten btree sol