Shortest distance between node

Can you please explain me the search function code here. When we are looking for the node in the left side of the tree why we are checking if left !=-1. I know to check if left is present but why we are not checking for right also before checking that condition.

I mean to say
why not int left=…
int right=…
then our if(left!=-1 or right!=-1)
{ return that particular node}

Hey @div_yanshu07
We checked left!=-1 because if its not then that means we fount the value so we can simply return it
otherwise if its -1 then it can be present/not present in right only so we are directly return right call

That should be done for right also right??

if(right!=-1) return right;

Why are we assuming the node is always present on our left?

we are not assuming if its not present then it will return -1 anyway
So u can add it like this as well if u want

I can add this condition right?? if(right!=-1)
?

like all the conditions??

yeah u can
if(left!=-1) return left;
if(right!=-1)return right;
return -1;