TernaryTree data structure