Cities of the second class and villages are empowered and authorized to receive, by gift or devise, and to purchase real estate within or without their corporate limits, for the purpose of parks, public grounds, swimming pools, or dams, either for recreational or conservational purposes. If such real estate is acquired by gift or devise, the title shall be vested in the city or village, upon the conditions imposed by the donor and upon the acceptance by the mayor and city council or the village board of trustees; and if such real estate is acquired by purchase, the title shall vest absolutely in such city or village.