throw a exception when exceed the max nesting