from typing import Dict


def get_score(tree_node: Dict, features: Dict) -> float:
    """
    Given a tree node and corresponding features, retrieve the weight.
    Recursive function. Depth is limited to the maximum tree depth in the forest.
    :param tree_node: Node or Leaf of the tree.
    :param features: Features to base decisions on, in the form of a sparse dict.
    :return: The score resulting from the input features.
    """
    # Example Node: {"f": 470, "c": 0, "u": "l", "l": {}, "r": {}}
    # Example Leaf: {"v": 32.0}
    if "v" in tree_node:
        return tree_node["v"]
    else:
        fidx = str(tree_node["f"])
        if fidx not in features:
            return get_score(tree_node[tree_node["u"]], features)
        elif features[fidx] < tree_node["c"]:
            return get_score(tree_node["l"], features)
        else:
            return get_score(tree_node["r"], features)