RecursionError: maximum recursion depth exceeded while calling a Python object

Quick fix ( I dont recommend this ) would be to set max_recursion_depth to something higher.

import sys
sys.setrecursionlimit(1500)

As @randyzwitch has mentioned the error is in your traversal method cek_pola, How about you change the traversal to iterative?

Its untested but you should be able to resolve your error by changing your function to this,

def cek_pola(cekdata,tree):
    stack = [tree]

    while stack:
        current_node = stack.pop()
        for nodes in tree.keys():        
            value = cekdata[nodes]
            tree = current_node[nodes][value]
            pola = 0

            if type(current_node) is dict:
                stack.append(tree)
            else:
                pola = tree
                break

    return pola

Hope it helps ! :slight_smile: