Generalizes more tree utils and updates bug in tag util.