def fraction_of_paths(paths_dict, fraction=1.):
    """Get fraction of strongest paths whose probability sum to a certain fraction.

    Parameters
    ----------
    paths_dict : dict.
        Dictionary of paths (tuple) and probabilities (float). Should be normalized, otherwise fraction might not
        actually get the fraction.

    fraction : float/int (default=1.).
        Find most likely paths which have a summed probability of at least 'fraction'.

    Returns
    -------
    new_dict : dict.
        Dictionary of most likely paths which have a summed probability of at least 'fraction'.
    """
    # Sort paths and probababilties from highest to lowest probability.
    sorted_probs, sorted_paths = zip(*sorted(zip(paths_dict.values(), paths_dict.keys()), reverse=True))
    probsum = 0

    for i, prob in enumerate(sorted_probs):
        probsum += prob

        # Enough paths to reach fraction?
        if probsum >= fraction:
            new_dict = dict(zip(sorted_paths[:i+1], sorted_probs[:i+1]))
            return new_dict
    # Not enough paths in whole dictionary to reach fraction.
    new_dict = paths_dict
    return new_dict