Tree algorithms