Question: Is it permissible for a person to take a pair similar to his shoes when the shoes have become mixed and confused—as happens in some large mosques and public gatherings, and as in the Sacred Mosque? Or is one required to refrain?
Answer—and Allah is the One who grants success: What appears to me is that when the shoes are mixed up and confused and distinguishing between them is impossible, they may be taken by reasonable estimation. If estimation is not possible, then let each person take what is similar to his shoes in newness and wear.
The jurists of the madhhab have said: A thing exits its owner’s ownership if it becomes mixed with another’s property such that distinguishing it is impossible. On that basis, we can say: the shoes, by virtue of mixing and confusion, have become unowned by any specific person; their proper disposition then is to the poor and to public interests.
Source: Min Thimār al-ʿIlm wa al-Ḥikmah vol.2