Iterates over all children of the current object, gathers the contents
    contributing to the resulting PGFPlots file, and returns those.

def _recurse(data, obj):
    """Iterates over all children of the current object, gathers the contents
    contributing to the resulting PGFPlots file, and returns those.
    """
    content = _ContentManager()
    for child in obj.get_children():
        # Some patches are Spines, too; skip those entirely.
        # See <https://github.com/nschloe/matplotlib2tikz/issues/277>.
        if isinstance(child, mpl.spines.Spine):
            continue

        if isinstance(child, mpl.axes.Axes):
            ax = axes.Axes(data, child)

            if ax.is_colorbar:
                continue

            # add extra axis options
            if data["extra axis options [base]"]:
                ax.axis_options.extend(data["extra axis options [base]"])

            data["current mpl axes obj"] = child
            data["current axes"] = ax

            # Run through the child objects, gather the content.
            data, children_content = _recurse(data, child)

            # populate content and add axis environment if desired
            if data["add axis environment"]:
                content.extend(
                    ax.get_begin_code() + children_content + [ax.get_end_code(data)], 0
                )
            else:
                content.extend(children_content, 0)
                # print axis environment options, if told to show infos
                if data["show_info"]:
                    print("=========================================================")
                    print("These would have been the properties of the environment:")
                    print("".join(ax.get_begin_code()[1:]))
                    print("=========================================================")
        elif isinstance(child, mpl.lines.Line2D):
            data, cont = line2d.draw_line2d(data, child)
            content.extend(cont, child.get_zorder())
        elif isinstance(child, mpl.image.AxesImage):
            data, cont = img.draw_image(data, child)
            content.extend(cont, child.get_zorder())
        elif isinstance(child, mpl.patches.Patch):
            data, cont = patch.draw_patch(data, child)
            content.extend(cont, child.get_zorder())
        elif isinstance(
            child, (mpl.collections.PatchCollection, mpl.collections.PolyCollection)
        ):
            data, cont = patch.draw_patchcollection(data, child)
            content.extend(cont, child.get_zorder())
        elif isinstance(child, mpl.collections.PathCollection):
            data, cont = path.draw_pathcollection(data, child)
            content.extend(cont, child.get_zorder())
        elif isinstance(child, mpl.collections.LineCollection):
            data, cont = line2d.draw_linecollection(data, child)
            content.extend(cont, child.get_zorder())
        elif isinstance(child, mpl.collections.QuadMesh):
            data, cont = qmsh.draw_quadmesh(data, child)
            content.extend(cont, child.get_zorder())
        elif isinstance(child, mpl.legend.Legend):
            data = legend.draw_legend(data, child)
            if data["legend colors"]:
                content.extend(data["legend colors"], 0)
        elif isinstance(child, (mpl.text.Text, mpl.text.Annotation)):
            data, cont = text.draw_text(data, child)
            content.extend(cont, child.get_zorder())
        elif isinstance(child, (mpl.axis.XAxis, mpl.axis.YAxis)):
            pass
        else:
            warnings.warn(
                "matplotlib2tikz: Don't know how to handle object {}.".format(
                    type(child)
                )
            )
    return data, content.flatten()