Node at distance k from the target node

can we like that instead of return 0 from the target node to their parent we return 1 and check if 1 == k the n print root node and else go to the rightsubtree