Pregunta de entrevista de S&P Global

Given a tree, create a function for a getting a sub-tree given P and K.