Composite Pattern example using JavaScript