def totuples(data):
    """ Convert python container tree to key/value tuples. """

    def crawl(obj, path):
        try:
            for key, value in sorted(obj.items()):
                yield from crawl(value, path + (key,))
        except AttributeError:
            if not isinstance(obj, str) and hasattr(obj, '__iter__'):
                for i, value in enumerate(obj):
                    yield from crawl(value, path + (i,))
            else:
                yield '.'.join(map(str, path)), obj
    return crawl(data, ())