import copy
import six


def _remove_empty(entry):
    """Remove any empty values and empty lists from entry."""
    new_entry = copy.deepcopy(entry)
    for key, value in six.iteritems(new_entry):
        if isinstance(value, dict):
            new_entry[key] = _remove_empty(value)

    emptykeys = [
        key
        for key, value in six.iteritems(new_entry)
        if not value
    ]
    for key in emptykeys:
        del new_entry[key]

    return new_entry