working implementation of mcs_tree