Rewrite 'if' to be recursive instead of table-based.