subttree algorithms