Text this: Algebraic and logical descriptions of generalized trees