Hierarchical organization and adaptive dynamics in relational systems