Fixes #3443: fix id autoincrement in recursion call