def compute_score(parsed):
    """
    If a node has no child node (len == 1), the score is the sum of the
    metadata, else the metadata are indexes of scores of child nodes. If an
    index does not exists, it is 0.
    """
    score = 0
    if len(parsed) == 1:
        # Only metadata
        score += sum(parsed['metadata'])
    else:
        indices = parsed['metadata']
        for indice in indices:
            try:
                child = parsed[indice]
            except KeyError:
                continue
            score += compute_score(child)
    return score