The solution to avoid infinite loop actually I needed to clear the array each time the new group of random Items is generated and some other bugs I fixed in the for loop
causing the if loop to crash.
UPDATE SOLUTION:
THANKS TO ALL OF UE4 SPECIALISTS HELPING ME FIX THIS PROBLEM
for (auto i = 1; i <= LocNumbers; ++i)
{
RandomItemType(LocItemType);
if (ItemsTypeArr.Find(LocItemType) == -1)
{
ItemsTypeArr.Add(LocItemType);
}
else if (ItemsTypeArr.Find(LocItemType) >= 1)
{
RandomItemType(LocItemType);
}
} ItemsTypeArr.Empty();