I'm using the Tridion Core Service to create Structure Groups and copy them to a specific Publication. I have this working but cannot nest the structure groups properly whilst creating them. I had the same issue when creating folders some time ago and found this article to be quite useful. It strips out the web dav path and creates folders by each part in the array.
However I cannot do this with structure groups as I need to also add a Directory, Metadata etc.
Does anyone know of the best way to go about doing this?