toJSON (stringify = true) {
    const props = {}
    if (this.priority) {
      props.priority = this.priority
    }
    if (this.name) {
      props.name = this.name
    }
    const oper = Condition.booleanOperator(this)
    if (oper) {
      if (Array.isArray(this[oper])) {
        props[oper] = this[oper].map((c) => c.toJSON(false))
      } else {
        props[oper] = this[oper].toJSON(false)
      }
    } else if (this.isConditionReference()) {
      props.condition = this.condition
    } else {
      props.operator = this.operator
      props.value = this.value
      props.fact = this.fact
      if (this.factResult !== undefined) {
        props.factResult = this.factResult
      }
      if (this.valueResult !== undefined) {
        props.valueResult = this.valueResult
      }
      if (this.result !== undefined) {
        props.result = this.result
      }
      if (this.params) {
        props.params = this.params
      }
      if (this.path) {
        props.path = this.path
      }
    }
    if (stringify) {
      return JSON.stringify(props)
    }
    return props
  }
Converts the condition into a json-friendly structure
@param   {Boolean} stringify - whether to return as a json string
@returns {string,object} json string or json-friendly object