The 0 char was encoded as just 0 (as the left->ch == 0 when it is a branch). Fix is to first compare right index, and if it doesn't match then use last left.