Creating Ternary Tree using Java