(e,t)=>{let r=[],i=(e,t)=>{Object.keys(e).forEach(o=>{1===t&&r.push(o);let n=t-1;n>0&&i(e[o],n)})};return i(e,t),r}

result

["y","p"]