An iterative rather than recursive implementation would be pretty easy and easier to understand.