/**
* Definition for a binary tree node.
* public class TreeNode {
* int val;
* TreeNode left;
* TreeNode right;
* TreeNode(int x) { val = x; }
* }
*/
class Solution {
public TreeNode searchBST(TreeNode root, int val) {
if(root==null){
return null;
}
if(root.val==val){
return root;
}
TreeNode t1=searchBST(root.left,val);
TreeNode t2=searchBST(root.right,val);
if(t1!=null){
return t1;
}
else if(t2!=null){
return t2;
}
else{
return null;
}
}
}