What specifically happens when you try to run it? Infinite loop?
Just from glancing at it, it looks like you're not decrementing lev before passing it into the functions to the right and the left. I believe if you fix that it will work (or at least have some new behavior that gets you closer), but I haven't tested it yet.
(edit) It also looks like res is being redeclared?
Not so fast naughty spawn! I want you to know about