def flatten(obj, entries):
    """
    Converts an object into a list of simple value pairs
    based on a list of entries to get and using the
    rule of nested object keys are declared as double underscores
    So to fro {'a': 1, 'b' : { 'b1': 3 }} you can get the 3 as 'b__b1'
    """
    result = {}
    for entry in entries:
        parts = entry.split('__')
        value_parts = obj[parts[0]]
        while len(parts) > 1:
            parts = parts[1:]
            value_parts = value_parts[parts[0]]
        result[entry] = value_parts.replace('\r\n', ' ') if type(value_parts
            ) is str else value_parts
    return result
