Mapping arrays of objects conditionally in Javascript I have array of objects with a multi-level nesting.