<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def coadd_maps(geom, maps, preserve_counts=True):
 """Coadd a sequence of `~gammapy.maps.Map` objects."""


    # FIXME: This functionality should be built into the Map.coadd method
    map_out = gammapy.maps.Map.from_geom(geom)
    for m in maps:
        m_tmp = m
        if isinstance(m, gammapy.maps.HpxNDMap):
            if m.geom.order < map_out.geom.order:
                factor = map_out.geom.nside // m.geom.nside
                m_tmp = m.upsample(factor, preserve_counts=preserve_counts)
        map_out.coadd(m_tmp)

    return map_out