Thank you - it was very useful!

So, now I have one level, but there was 2 of them... Is it possible to use regex in index function? For example, how to find Aaaa->Bbbbb and insert it before 3rd level?
Ideas like:
awk 'if (index ($0, "[A-Za-z+->A-Za-z+]")>0) {print base $0} else {base = $0}} ' filename
does not work...
or maybe it is not necesarry to use regexes...