def iterate_pagerank(corpus, damping_factor):
    """
    Return PageRank values for each page by iteratively updating
    PageRank values until convergence.

    Return a dictionary where keys are page names, and values are
    their estimated PageRank value (a value between 0 and 1). All
    PageRank values should sum to 1.
    """
    #initalize page ranks
    page_ranks = dict()
    for key in corpus.keys():
        page_ranks.update({key : float(1) / len(corpus.keys())})

    while True:
        #Make a copy of old values to use in comparison later
        old_page_ranks = page_ranks.copy()

        #Calculate page rank
        for key in corpus.keys():
            page_ranks_value = float(1 - damping_factor) / len(corpus.keys())

            for other_key in corpus.keys():
                if len(corpus[other_key]) == 0:
                    page_ranks_value += float(damping_factor) * old_page_ranks[other_key] / len(corpus.keys())

                elif corpus[other_key].issuperset({key}):
                    page_ranks_value += float(damping_factor) * old_page_ranks[other_key] / len(corpus[other_key])

            page_ranks[key] = page_ranks_value

        #break out of while loop if no page changed by > 0.001
        break_loop = True

        for key in corpus.keys():
            difference = old_page_ranks[key] - page_ranks[key]
            if difference < -0.001 or difference > 0.001:
                break_loop = False
                break

        if break_loop:
            break

    return page_ranks