I strongly recommend you to read "Clean Code" by Robert Martin, an extract of which says about nested structures:
Blocks and Indenting
...the blocks within if
statements, else
statements, while
statements, and so on should be one line long. Probably that line
should be a function call. Not only does this keep the enclosing
function small, but it also adds documentary value because the
function called within the block can have a nicely descriptive name.
This also implies that functions should not be large enough to hold
nested structures. Therefore, the indent level of a function
should not be greater than one or two. This, of course, makes the
functions easier to read and understand.
So Bob Martin's recommendation is that the dept of nested structured should be two at most.
I agree with that and, although I don't always comply with it, at least I try.
Also, according with static analisys tool PDM's default configuration, the cyclomatic complexity of a function should not exceed 11, which is easily reached if you go beyond a dept of two.