code: def find_substring(substring, suffix_tree, edge_repo):
      
      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
docs: Returns the index if substring in tree, otherwise -1.