public static int maxOccurance(TreeNode root, int t) {
    	TreeIterator i=new TreeIterator(root);
    	int c1=0,v1=0,c2=0,v2=0,cmax=0;
    	boolean f1=false,f2=false;
    	while (i.hasNext()) {
    		TreeNode c=i.next();
    		if (!f1) {
    			f1=true;
    			c1=1;
    			v1=c.val;
    		} else if (f1&&c.val==v1) {
    			++c1;
    		}
    		if (!f2) {
    			f2=true;
    			c2=1;
    			v2=c.val;
    		} else if (f2&&c.val==v2) {
    			++c2;
    		}
    		cmax=Math.max(c1, c2);
    		if (c.val!=v1&&c.val!=v2) {
    			v1=v2;
    			c1=c2;
    			c2=1;
    			v2=c.val;
    		}
    	}
    	return cmax;
    }