removeLeafNodes = function(root, target) {
    
    const dfs = (node) => {
        if (!node) return null;
        node.left = dfs(node.left);
        node.right = dfs(node.right);
        if (!node.left && !node.right) {
            if (node.val === target) return null;
        }
        return node;
    }

    return dfs(root);
}
DFS | PostOrder traversal
Time O(n) | Space O(n)
https://leetcode.com/problems/delete-leaves-with-a-given-value
@param {TreeNode} root
@param {number} target
@return {TreeNode}