There are two options. To create a cdef class instead of a struct, i.e.
cdef class TrieNode
cdef list children
cdef object value
(Unfortunately we don't have a way to type the members of the list...)
This should still be rather efficient. Alternatively, you can do
from cpython cimport PyObject
DEF SIZE = 62
cdef struct TrieNode:
TrieNode *children[SIZE] # or just *children
PyObject* value
and manually incref/decref the value node (and, of course, allocate
memory for the children, you can't have a struct that contains itself
or an array of itself--what would the memory layout look like?).
Personally, I think the cdef class option is much cleaner.
- Robert