# Path: inspire_schemas/utils.py
# EMPTIES = [None, '', [], {}]
# 
# def filter_empty_parameters(func):
#     """Decorator that is filtering empty parameters.
# 
#     :param func: function that you want wrapping
#     :type func: function
#     """
#     @wraps(func)
#     def func_wrapper(self, *args, **kwargs):
#         my_kwargs = {key: value for key, value in kwargs.items()
#                      if value not in EMPTIES}
#         args_is_empty = all(arg in EMPTIES for arg in args)
# 
#         if (
#                 {'source', 'material'}.issuperset(my_kwargs) or not my_kwargs
#         ) and args_is_empty:
#             return
#         return func(self, *args, **my_kwargs)
# 
#     return func_wrapper


import six
from ..utils import EMPTIES, filter_empty_parameters
                self.record[field].append(element)
        elif kwargs:
            if 'record' in kwargs and isinstance(kwargs['record'], six.string_types):
                kwargs['record'] = {'$ref': kwargs['record']}
            self._ensure_list_field(field, default_list)
            if kwargs not in self.record[field]:
                self.record[field].append(kwargs)

    def _ensure_field(self, field_name, default_value, obj=None):
        if obj is None:
            obj = self.record
        if field_name not in obj:
            obj[field_name] = default_value

    def _ensure_list_field(self, field_name, default_value=None, obj=None):
        if default_value is None:
            default_value = []
        self._ensure_field(field_name, default_value, obj)

    def _ensure_dict_field(self, field_name, default_value=None, obj=None):
        if default_value is None:
            default_value = {}
        self._ensure_field(field_name, default_value, obj)

    def _sourced_dict(self, source=None, **kwargs):
        if source:
            kwargs['source'] = source
        elif self.source:
            kwargs['source'] = self.source


# Path: inspire_schemas/utils.py
# EMPTIES = [None, '', [], {}]
# 
# def filter_empty_parameters(func):
#     """Decorator that is filtering empty parameters.
# 
#     :param func: function that you want wrapping
#     :type func: function
#     """
#     @wraps(func)
#     def func_wrapper(self, *args, **kwargs):
#         my_kwargs = {key: value for key, value in kwargs.items()
#                      if value not in EMPTIES}
#         args_is_empty = all(arg in EMPTIES for arg in args)
# 
#         if (
#                 {'source', 'material'}.issuperset(my_kwargs) or not my_kwargs
#         ) and args_is_empty:
#             return
#         return func(self, *args, **my_kwargs)
# 
#     return func_wrapper


# Path: inspire_schemas/builders/builder.py
import six
from ..utils import EMPTIES, filter_empty_parameters

                self.record[field].append(element)
        elif kwargs:
            if 'record' in kwargs and isinstance(kwargs['record'], six.string_types):
                kwargs['record'] = {'$ref': kwargs['record']}
            self._ensure_list_field(field, default_list)
            if kwargs not in self.record[field]:
                self.record[field].append(kwargs)

    def _ensure_field(self, field_name, default_value, obj=None):
        if obj is None:
            obj = self.record
        if field_name not in obj:
            obj[field_name] = default_value

    def _ensure_list_field(self, field_name, default_value=None, obj=None):
        if default_value is None:
            default_value = []
        self._ensure_field(field_name, default_value, obj)

    def _ensure_dict_field(self, field_name, default_value=None, obj=None):
        if default_value is None:
            default_value = {}
        self._ensure_field(field_name, default_value, obj)

    def _sourced_dict(self, source=None, **kwargs):
        if source:
            kwargs['source'] = source
        elif self.source:
            kwargs['source'] = self.source


        return {key: value for key, value in kwargs.items() if value not in EMPTIES}