group files using trie structure