Moved assert out of recursive method.