static int lcaHelper(TreeNode node, TreeNode A, TreeNode B, TreeNode[]rel) {
        if (node==null||rel[0]!=null)
            return 0;
        int sum=0;
        if (node.val==A.val&&A.val==B.val) {
            rel[0]=node;
            return 2;
        }
        
        if (node.val==A.val||node.val==B.val) {
            sum=1;
        }
        
        sum+=lcaHelper(node.left,A,B,rel)+lcaHelper(node.right,A,B,rel);
        if (sum==2&&rel[0]==null) {
            rel[0]=node;
        }
        return sum;
    }