code: def validate(self, node):
          
          assert isinstance(node, Node)
          if isinstance(node.operator, Logical):
              self.validate(node.left)
              self.validate(node.right)
              return
          assert isinstance(node.left, Name)
          assert isinstance(node.operator, Comparison)
          assert isinstance(node.right, (Const, List))
  
          # Check that field and value types are compatible
          field = self.resolve_name(node.left)
          value = node.right.value
          if field is None:
              if value is not None:
                  raise DjangoQLSchemaError(
                      'Related model %s can be compared to None only, but not to '
                      '%s' % (node.left.value, type(value).__name__)
                  )
          else:
              values = value if isinstance(node.right, List) else [value]
              for v in values:
                  field.validate(v)
docs: Validate DjangoQL AST tree vs. current schema