export class Node < T > { data : T ; parent : this | null ; children : Map < T , this > ; constructor ( data ) { this . data = data ; this . children = new Map ( ) ; this . parent = null ; } addChild ( node ) { node . parent = this ; this . children . set ( node . data , node ) ; } removeChild ( node ) { this . children . delete ( node . data ) ; } }