I have a data structure like below:
var options = [{
        name: "Option One",
        foo: "bar",
        values: [{
            name: "Value One",
            value: "Value",
            options: [{
                name: "Option Two",
                values: [{
                    name: "Value Two",
                    value: "Value",
                    options: []
                }]
            }]
        }]
    }, {
        name: "Option Three",
        values: [{
            name: "Value Three",
            value: "Value",
            options: []
        }]
    }];
I need to flatten it, filter out properties I don't want and keep knowledge of the depth of each object like the below data structure:
var flattenedFilteredOptions = [{
        depth: 0,
        name: "Option One",
        values: [{
            name: "Value One",
            value: "Value"
        }]
    }, {
        depth: 1,
        name: "Option Two",
        values: [{
            name: "Value Two",
            value: "Value"
        }]
    }, {
        depth: 0,
        name: "Option Three",
        values: [{
            name: "Value Three",
            value: "Value"
        }]
    }];
So basically I only want the properties of name, values, and value in the output. Can someone point me in the right direction to even start something like this or does anyone have a solution?
