add ternary tree for auto completion