Here in this code they are checking the equality of self with the other two parameters.
What? Where? No. a and b == c
doesn't relate a
and c
together in any way.
self.parent and self.parent.leftChild == self
checks if
self.parent
has a meaningful value (is not None
) and, if so,
self.parent.leftChild
equals to the given self
.
In other words, it does what its name says: it checks if "we" are identical to our parent's left child. This, of course, only works if we have a parent. If we haven't, we aren't its left child.
Note: What I just said about "is not None
" is only half the truth. To be exact, it checks if there is a "truthy value", i. e. a value which evaluates true in the context of conditional expressions. As one normally uses None
in the case of an absent node such as parent
, what I wrote is clear enough.