tree_cut implementation