get root ancestor for AC automaton