<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def find_substring(substring, suffix_tree, edge_repo):
 """Returns the index if substring in tree, otherwise -1. """

    assert isinstance(substring, str)
    assert isinstance(suffix_tree, SuffixTree)
    assert isinstance(edge_repo, EventSourcedRepository)
    if not substring:
        return -1
    if suffix_tree.case_insensitive:
        substring = substring.lower()
    curr_node_id = suffix_tree.root_node_id
    i = 0
    while i < len(substring):
        edge_id = make_edge_id(curr_node_id, substring[i])
        try:
            edge = edge_repo[edge_id]
        except RepositoryKeyError:
            return -1
        ln = min(edge.length + 1, len(substring) - i)
        if substring[i:i + ln] != suffix_tree.string[edge.first_char_index:edge.first_char_index + ln]:
            return -1
        i += edge.length + 1
        curr_node_id = edge.dest_node_id
    return edge.first_char_index - len(substring) + ln