A Trie-Based Approach for Compacting Automata