private void FindInField(int depthLimit, FieldInfo f, int arrayIdx, object fieldValue, string path) { if (depthLimit <= 0) { return; } if (fieldValue != null) { if (type.IsAssignableFrom(fieldValue.GetType())) { AddResult(instances, f, fieldValue); } else { string name = f.GetName(true) + (arrayIdx == -1 ? "" : "[" + arrayIdx + "]"); var instancesOfFieldValue = FindInstancesIn(fieldValue, depthLimit - 1, path + " -> " + name); if (instancesOfFieldValue != null) { instances.AddRange(instances); } } object[] array = LocalsHelper.AsObjectArrayFromIenumerable(fieldValue); if (array != null) { // check items for (int i = 0; i < array.Length; i++) { FindInField(depthLimit - 1, f, i, array[i], path); } } } }