Создание класса внутри класса не запрещено в JS:
class Node {
constructor(a, b, x, y) {
this.a = a;
this.b = b;
class Tree {
constructor(c, d) {
this.c = c;
this.d = d;
}
}
this.tree = new Tree(x, y);
}
}
let node = new Node(1, 2, 3, 4);
console.log(node.a, node.b, node.tree.c, node.tree.d)
// 1 2 3 4 - Exactly the same as the arguments passed to Node