<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def map(cls, visitor, value, value_type):
 """The common visitor API used by all three visitor implementations. args: ``visitor=``\ *Visitor* Visitor options instance: contains the callbacks to use to implement the visiting, as well as traversal & filtering options. ``value=``\ *Object* Object being visited ``value_type=``\ *RecordType* The type object controlling the visiting. """

        unpacked = visitor.unpack(value, value_type, visitor)

        if unpacked == cls.StopVisiting or isinstance(
            unpacked, cls.StopVisiting
        ):
            return unpacked.return_value

        if isinstance(unpacked, tuple):
            props, coll = unpacked
        else:
            props, coll = unpacked, None

        # recurse into values for collections
        if coll:
            coll_map_generator = cls.map_collection(
                visitor, coll, value_type,
            )
            mapped_coll = visitor.collect(
                coll_map_generator, value_type, visitor,
            )
        else:
            mapped_coll = None

        # recurse into regular properties
        mapped_props = None
        if props:
            mapped_props = cls.map_record(visitor, props, value_type)
        elif mapped_coll is None:
            return visitor.apply(value, None, visitor)

        return visitor.reduce(
            mapped_props, mapped_coll, value_type, visitor,
        )