val
and set the original tree as its left child.insert
starting from the root node with the current depth as 1.insert
function, check if the current depth is one less than the target depth.val
and attach the original left and right subtrees to these new nodes.insert
for the left and right subtrees, incrementing the depth.