Print nodes at a distance k from a given node (bst)

my code works for the test case but on submission it gives wrong answer
i have added comments for ease of understanding
please tell me an example of test case that my code isnt able to handle
please help me

my code
https://ide.codingblocks.com/s/49704

question link
https://hack.codingblocks.com/contests/c/511/1604

Hi Jai,
Consider the following example,
7
20 8 4 12 10 14 22
4 8 10 12 14 20 22
2
8 2
14 3

The output should be:
10 14 22
4 20

Your code gives:
10 14 10 14 22
4 4

This will be the tree for your reference.

8 => 20 <= 22
4 => 8 <= 12
END => 4 <= END
10 => 12 <= 14
END => 10 <= END
END => 14 <= END
END => 22 <= END

i have modified my code but still it gives wrong answer on submission
please tell me what test case is my code not able to handle

https://ide.codingblocks.com/s/50746

thanks in advance

Consider the following case:
5
1 2 3 4 5
2 1 4 5 3
1
5 3
The output should be: 1
Your code gives: 1 0
The tree is:
2 => 1 <= 3
END => 2 <= END
4 => 3 <= END
END => 4 <= 5
END => 5 <= END

further corrected my code but still failing two cases on submission
please help me ,
for what test case is my code giving wrong output

https://ide.codingblocks.com/s/51402

thanks in advance

for what test case is my code giving wrong output
please help me sir/maam

please help me pass all the test cases …

@tusharsk
@sanjeetboora