Hi all,

can someone give me an idea how to make to work something like this:

For example I have:

After it has to be:

That was simple, now when I get something like this:

I must get
and then
a1b1d1e1,a1b1d1e2,a1b1d2e1,a1b1d2e2 and so on,
I see it will be very long.

Anyway, problem is, how to know how many levels I have (in the last situation only two) but it can be x, so how do I know which one to start from?

P.S. I get a string, and have to return a string as a result.

Any help is appreciated,
ty in advance