[api] Fix #388 Maximum recursion