<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def to_json_dict(self, filter_fcn=None):
 """Create a dict with Entity properties for json encoding. It can be overridden by subclasses for each standard serialization doesn't work. By default it call _to_json_dict on OneToOne fields and build a list calling the same method on each OneToMany object's fields. Fields can be filtered accordingly to 'filter_fcn'. This callable receives field's name as first parameter and fields itself as second parameter. It must return True if field's value should be included on dict and False otherwise. If not provided field will not be filtered. :type filter_fcn: callable :return: dct """

        fields, values = self.get_fields(), self.get_values()
        filtered_fields = fields.items()
        if filter_fcn is not None:
            filtered_fields = (
                tpl for tpl in filtered_fields if filter_fcn(tpl[0], tpl[1])
            )
        json_dct = {}
        for field_name, field in filtered_fields:
            if field_name in values:
                value = values[field_name]
                if value is None:
                    json_dct[field_name] = None
                    # This conditions is needed because some times you get
                    # None on an OneToOneField what lead to an error
                    # on bellow condition, e.g., calling value.to_json_dict()
                    # when value is None
                elif isinstance(field, OneToOneField):
                    json_dct[field_name] = value.to_json_dict()
                elif isinstance(field, OneToManyField):
                    json_dct[field_name] = [
                        entity.to_json_dict() for entity in value
                    ]
                else:
                    json_dct[field_name] = to_json_serializable(value)
        return json_dct