it 's a leaf, so print the ancestor at distance k only  if the ancestor is not already printed
if ( node -> left == NULL && node -> right == NULL && pathLen - k - 1 >= 0 && visited [ pathLen - k - 1 ] == false ) { cout << path [ pathLen - k - 1 ] << " ▁ " ; visited [ pathLen - k - 1 ] = true ; return ; }