Stopping Unity from freeze when using while and random together

Hey! Probably this is a repeated question, but none of the answers in other’s questions answer my perticular question.
So I have a list of Vector3s and I add a offset value in it when a new offset is generated. I use a random function to do it. But since I want different Vector3s in the list i use a do while loop to check if the randomly generated Vector3 already exists in the list, if it does I re-run the do while loop untill the new vector3 is generated.

List<Vector3> mylist = nee list<Vector3>();
Vector3 currentoffset = new Vector3 (0,0,0);

void Start() {
mylist.Add(currentoffset);
for(int i=0: i<20;i++)
do {
 //restore previous currentoffset value;
//randomly change currentoffset (by adding or subtracting 4 in x and z places);
} while(!mylist.Contains(currentoffset);
mylist.Add(currentoffset);
}
}

PS. The code is pseudo and has bo errors when applied, the only problem is occasional freezing of Unity editor and can’t seem to find another way of implementing similar code.

Edit: And I aslo know that within the combination in do while loop atleast one combination will never be in the list.

Thanks for helping!

i think you could replace while with an if statement.
if(!mylist.Contains(vector3){mylist.add(vector3)…