There is something about nested ifs that does not please my eye
Recursion, did you mean recursion?
cond helps here