def match_all(string, trie):
 matches = []
 for i in range(len(string)):
  substr = string[:(i + 1)]
  if (not trie.has_prefix(substr)):
   break
  if (substr in trie):
   matches.append(substr)
 return matches

def match_all ( string , trie ) : matches = [ ] for i in range ( len ( string ) ) : substr = string [ : ( i + 1 ) ] if ( not trie . has_prefix ( substr ) ) : break if ( substr in trie ) : matches . append ( substr ) return matches
match_all -> list of keys find all the keys in the trie that matches the beginning of the string .