title: Recursive javascript function returns undefined
body: <p>I have this array of objects which I'm trying to parse so I can get the fields from one instance I have</p>
  
  <pre><code>const obj = [{
    'name': 'A',
    'type': 'group',
    'fields': [a_bunch_of_objs],
    'instances': [
      {
        name: 'AA',
        'type': 'group',
        'fields': [a_bunch_of_objs],
        'instances': [
          {
            'name': 'AAA',
            'type': 'group',
            'fields': [a_bunch_of_objs],
            'instances': []
          }
        ]
      }
    ]
  },
  {
    'name': 'B',
    'type': 'bla',
    'instances': []
  }];
  </code></pre>
  
  <p>I have a recursive function</p>
  
  <pre><code>getInstanceFields: function(form_fields, instance_name) {
      var self = this;
      form_fields.forEach(function(field) {
        if (field.field_type === 'group') {
          field.instances.forEach(function(instance) {
            if (instance.name === instance_name) {
              return instance.fields;
            } else {
              return self.getInstanceFields(instance.fields, instance_name);
            }
          });
        }
      });
    },
  </code></pre>
  
  <p>which I'm calling like this: getInstanceFields(obj, 'name_to_search_for');</p>
  
  <p>Problem is that if I add a console log before returning <code>instance.fields</code> I see the correct values, but if the actual returned result is <code>undefined</code>.</p>
  
  <p>Any clues as to what I'm missing here?</p>