There exists a helper function map_get_surface_element_at which already searches a tile's element list for the surface element, so we can just use that.