working cython version of tree_node