export function getDescendants < T > ( root , getChildren ) { const results = [ ] ; inner ( root ) ; return results ; function inner ( item ) { getChildren ( item ) . forEach ( ( x ) => { if ( ! results . includes ( x ) ) { results . push ( x ) ; inner ( x ) ; } } ) ; } }