The basic idea is the traverse the whole binary tree and store the val in each node.

The returned list should be sorted in increased order, otherwise the tree is not BST.

```
public boolean isValidBST(TreeNode root) {
ArrayList<Integer> list = new ArrayList<>();
val_list(root, list);
if(list.size()>1)
for(int i=1;i<list.size();i++){
if(list.get(i-1)>=list.get(i)){
return false;
}
}
return true;
}
public void val_list(TreeNode node,ArrayList<Integer> list){
if(node==null){
return;
}
val_list(node.left,list);
list.add(node.val);
val_list(node.right, list);
}
```