Add ternary tree class