# 1325. Delete Leaves With a Given Value ###### tags: `Leetcode` `Medium` `Bloomberg` `DFS` Link: https://leetcode.com/problems/delete-leaves-with-a-given-value/ ## Code ```java= class Solution { public TreeNode removeLeafNodes(TreeNode root, int target) { if(root == null) return null; root.left = removeLeafNodes(root.left, target); root.right = removeLeafNodes(root.right, target); if(root.val == target && root.left == null && root.right == null) return null; return root; } } ```