Similar Items: Learning Tree Automata with Term Rewriting