By "collection", I mean any mathematical object which can contain other mathematical objects as elements. For example a set, a tuple, a sequence, a class, a vector. If you know what a collection is in Java: That's what I'm talking about. (See "All Known Subinterfaces" and "All Known Implementing Classes" on this page.)
For sets, it's easy as pretty much the first thing I learned about sets is that they can't contain themselves (as this would violate the axiom of regularity). But can – for example – a tuple contain itself as an element? Is there something else preventing this?
This depends on your foundations of mathematics.
If your foundations is based on set theory, then Regularity implies that nothing contains itself. Not sets, not classes, not nothing.
On the other hand, your foundation can be a "less-standard" set theory (e.g. set theory without Regularity, or something like Quine's New Foundations which contradict Regularity altogether), in which case it might be that some specific collections do contain themselves. In some type theoretic situations, one can sort of get to the situation where some types contain themselves, as well. But I am not an expert on this subject. Although it seems to be the exact point on which you are asking with the function $f$.