Collect all elements in a geometry

Could you tell where does this code come from and what you tried to change in it?
See also here how to paste code in a post: