'Recurses through dicts and/or lists and flattens them
into a single level dict of key: value pairs.  Each
key consists of all of the recursed keys joined by
separator.  If key_filter_callback is callable,
it will be called with each key.  It should return
either a new key which will be used in the final full
key string, or False, which will indicate that this
key and its value should be skipped.'

def flatten_object(self, node, separator='.', key_filter_callback=None, parent_keys=[]):

    items = {}
    try:
        if (sys.version_info >= (3, 0)):
            iterator = iter(node.items())
        else:
            iterator = node.iteritems()
    except AttributeError:
        iterator = enumerate(node)
    for (key, item) in iterator:
        if callable(key_filter_callback):
            key = key_filter_callback(key)
        if (key is False):
            continue
        if (type(item) in (list, dict)):
            items.update(self.flatten_object(item, separator, key_filter_callback, (parent_keys + [str(key)])))
        else:
            final_key = separator.join((parent_keys + [str(key)]))
            items[final_key] = item
    return items
