def search_unique(table, sample, unique_fields=None):
if unique_fields is None:<EOL><INDENT>unique_fields = list(sample.keys())<EOL><DEDENT>query = _query_data(sample, field_names=unique_fields, operators='<STR_LIT>')<EOL>items = table.search(query)<EOL>if len(items) == <NUM_LIT:1>:<EOL><INDENT>return items[<NUM_LIT:0>]<EOL><DEDENT>if len(items) == <NUM_LIT:0>:<EOL><INDENT>return None<EOL><DEDENT>raise MoreThanOneItemError('<STR_LIT>'<EOL>'<STR_LIT>'.format(len(items)))<EOL>
Search for items in `table` that have the same field sub-set values as in `sample`.
    Expecting it to be unique, otherwise will raise an exception.

    Parameters
    ----------
    table: tinydb.table
    sample: dict
        Sample data

    Returns
    -------
    search_result: tinydb.database.Element
        Unique item result of the search.

    Raises
    ------
    KeyError:
        If the search returns for more than one entry.