Add to_string method to convert hierarchical model to string