Where is error in Kth node code of tree

please correct and comment the error


new logic for down, minor changes otherwise

detailed explanation of this logic with comments

what is the logic of k-l-2 and k-r-2 as in video it was mentioned about k-l-1 and k-r-1. Please tell.

if u found that this left node it not valid
then u have to go the right node
for a root
if a left node is at distance 1
then from the left node the right node is at distance 2, at one distance root and from root u need another step so two steps