def _find_repeated_substrings(s, chunk_size, min_str_size):
    """Find all of the repeated substrings in a given string that are longer
    than a certain length. This assumes that repeated substrings of interest
    show up in a prefix of a given size.

    @param s (str) The string to check for repeated substrings. Only
    a prefix of the string will be checked.

    @param chunk_size (int) The size of the string prefix to check for
    repeated substrings. If bigger than the given string length an
    empty set will be returned.

    @param min_str_size (int) The minimum substring size to
    track. Shorter repeated substrings will not be reported.

    @return (set) A set of repeated substrings.

    """
    
    # If there is a repeated string it will show up in the 1st NN characters
    # of the string.
    if (chunk_size > len(s)):
        return set()
    chunk = s[:chunk_size]

    # Start looking for repeats of substrings of length 2 in the chunk.
    pos = -1
    window_size = 2
    r = set()
    while ((pos + window_size) < len(chunk)):

        # Is this 2 character chunk repeated?
        pos += 1
        curr_str = chunk[pos:pos + window_size]
        if (s.count(curr_str) > 1):

            # Start adding 1 character at at time to the substring until
            # we find no more repeats. This should give us the longest
            # repeated substring with the current prefix.
            tmp_window_size = 3
            old_curr_str = None
            while ((s.count(curr_str) > 1) and
                   ((pos + tmp_window_size) < len(chunk))):
                old_curr_str = curr_str
                curr_str = chunk[pos:pos + tmp_window_size]
                tmp_window_size += 1

            # Found an acceptable repeated substring?
            if ((old_curr_str is not None) and
                (len(old_curr_str.strip()) >= min_str_size)):

                # Save the full string.
                r.add(old_curr_str)

                # If this is a large string some substrings may be more
                # common repeats. Add some of those.
                if (len(old_curr_str) > min_str_size*3):
                    for i in range(1, len(old_curr_str) - min_str_size*3):
                        r.add(old_curr_str[:i*-1])

    # Done
    return r