Tree = type(NodeData) variant { LEAF(data:: NodeData), GROUP(nodes:: [ref(Tree(NodeData))]) } Guard = type variant { a, b }. DecisionTree = type Tree(Guard). buildTable = function(nodes:: [DecisionTree], size:: i32):: [ DecisionTree ] { tableInit = arr_create(size):: [DecisionTree]. loop fold(nodes->node:: DecisionTree, tableInit->table):: [DecisionTree] { switch variant(node):: [DecisionTree] case (LEAF) { table + { LEAF(node["data"]) } } case (GROUP) { table + GROUP(buildTable(nodes["nodes"])) } } }