Encoded Binary Relations and Tree-Structured Documents -- Theoretical and Practical