'Translate fields\' paths to their db equivalents.'

def _fields_to_dbfields(self, fields):

    subclasses = []
    if self._document._meta['allow_inheritance']:
        subclasses = [get_document(x) for x in self._document._subclasses][1:]
    db_field_paths = []
    for field in fields:
        field_parts = field.split('.')
        try:
            field = '.'.join(((f if isinstance(f, six.string_types) else f.db_field) for f in self._document._lookup_field(field_parts)))
            db_field_paths.append(field)
        except LookUpError as err:
            found = False
            for subdoc in subclasses:
                try:
                    subfield = '.'.join(((f if isinstance(f, six.string_types) else f.db_field) for f in subdoc._lookup_field(field_parts)))
                    db_field_paths.append(subfield)
                    found = True
                    break
                except LookUpError:
                    pass
            if (not found):
                raise err
    return db_field_paths
