Recursive naive implementation.