Creates a ternary tree.