Rewrite to be a little more idiomatic by avoiding explicit recursion
Make use of the fact that [] is an instance of MonadPlus.