Nevermind, it appears that stack overflow in my case is the same as infinite recursion. The only problem is how to avoid infinite recursion in this case, therefore I'll just request this topic be deleted.