Map<String, Object?> toJson() => { 'kind': kind, if (isBarriered) 'isBarriered': true, 'nodes': nodes.map((n) => n.toJson()).toList(), };