update the sampling code to deal with trees without branches