I have this structure of List, to be specific it is a \"CategoryItem\" Object. Here\'s my declaration of \"CategoryItem\" Object.
List
A simple not optimal but simple solution will be to just iterate the list and for each of the items you count how many times you call its parent id before it its 0. So then you know how many levels of identation your must have.