private boolean isValid(TreeNode node, int minValue, int maxValue) {
    	
    	if (node == null)
    		return true;
    	
    	if (node.val <= minValue || node.val >= maxValue)
    		return false;
    	
		return isValid(node.left, minValue, node.val) && isValid(node.right, node.val, maxValue);
	}