def paths_to_endnode(paths):
    """Take dictionary of paths (keys) and their probability (values) and remove everything except the last node of the
    path from the key. Is useful for assigning genotypes to clusters based on their relative probability of reaching a
    certain peak.
    """
    endnode_dict = {}
    for path, prob in paths.items():
        try:
            endnode_dict[path[-1]] += prob
        except KeyError:
            endnode_dict[path[-1]] = prob
    return endnode_dict
