public TreeNode findNextNode(TreeNode node){
        if(node.right==null){
            //if this is to right of parent, with no children, there is no next node
            if(node.parent==null || node.parent.right == node){
                return null;
            }
            //if this is to left of parent with no children, parent is next
            return node.parent;
        }
        else if(node.right != null){
            TreeNode current = node.right;
            while(current.left!=null){
                current = current.left;
            }
            return current;
        }
        //this is never reached
        return null;
    }