S&P Global Interview Question

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