The first thing came to my mind were the guard clauses that helped me to isolate the code not related to the algorithm itself. Doing this, instead of nested conditionals we got a "flat" list of ...