class Node {
constructor(value) {
this.value = value
this.left = null
this.right = null
this.children = []
}
insert (value) {
if (value === this.value) return;
if (value > this.value) {
if (this.right) {
this.right.insert(value)
} else {
this.right = new Node(value)
this.children.push(this.right)
}
} else if (value < this.value) {
if (this.left) {
this.left.insert(value)
} else {
this.left = new Node(value)
this.children.push(this.left)
}
}
}
}