Combine nested list items into one multiline string

Hi everyone,
i would like to ask for help with creating multiline string from nested list. In the image below i manage to create list with layers of compound elements. The list contains material and its thickness. I want to create from those items multiline parameter and write it into shared type parameter.
After a lot of searching and experiments i could manage to do it so.
Any idea how to continue? My idea is to manage to create one dimensional list with combined strings with newline element between those values and than use it to set parameter by value.
Thank you for any help.