The explained logic seems not to be correct

The logic is not correct because the return statement is a number and cannot be None. So, leftTreeHeight and rightTreeHeight are numbers and they cannot be None. The condition below is always True and can be removed.
if leftTreeHeight is not None and rightTreeHeight is not None:

Hi @Yashar_Zargari_Zonou,
You are right. In the python implementation, the statement should check for 0 rather than None as done in the rest of the implementations.