<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _get_insertion_index(routing_table, generality):
 """Determine the index in the routing table where a new entry should be inserted. """

    # We insert before blocks of equivalent generality, so decrement the given
    # generality.
    generality -= 1

    # Wrapper for _get_generality which accepts a routing entry
    def gg(entry):
        return _get_generality(entry.key, entry.mask)

    # Perform a binary search through the routing table
    bottom = 0
    top = len(routing_table)
    pos = (top - bottom) // 2

    pg = gg(routing_table[pos])
    while pg != generality and bottom < pos < top:
        if pg < generality:
            bottom = pos  # Move up
        else:  # pg > generality
            top = pos  # Move down

        # Compute a new position
        pos = bottom + (top - bottom) // 2
        pg = gg(routing_table[pos])

    while (pos < len(routing_table) and
           gg(routing_table[pos]) <= generality):
        pos += 1

    return pos