public static IEnumerable<Dictionary<FieldInfo, string>> GetAllProfileCombinationsForInstance(BaseBehaviour instance)
    {
        var dict = new Dictionary<FieldInfo, List<string>>();

        foreach (var fieldOuter in instance.GetType().GetFields(BindingFlags.Public | BindingFlags.Instance))
        {
            var attributes = fieldOuter.GetCustomAttributes(typeof (SettingInstanceNameSelectorAttribute), true);

            if (attributes.Length > 0)
            {
                var fieldOptions = new List<string>();
                var range = (SettingInstanceNameSelectorAttribute) attributes[0];

                if (_configurationGameObjects == null)
                {
                    _configurationGameObjects = Resources.LoadAll("Configuration").OfType<GameObject>().ToList();
                }

                foreach (var res in _configurationGameObjects)
                {
                    var components = res.GetComponents(range.BaseSettingStoreType);
                    if (components.Length > 0)
                    {
                        var settingsStoreInstanceName =
                            (from field in
                                components[0].GetType().GetFields(BindingFlags.Public | BindingFlags.Instance)
                                    .OrderBy(x => x.FieldType.Name)
                                    .ThenBy(x => x.Name)
                                let attrs = field.GetCustomAttributes(false)
                                where attrs.OfType<SettingInstanceNameAttribute>().Any()
                                select (string) field.GetValue(components[0])).FirstOrDefault();

                        fieldOptions.Add(settingsStoreInstanceName);
                    }
                }

                dict[fieldOuter] = fieldOptions;
            }
        }

        var fields = dict.Keys.ToList();
        var stack = new Stack<int>();

        while (fields.Count != 0)
        {
            if (stack.Count < fields.Count)
            {
                stack.Push(0);
            }
            else if (stack.Count == fields.Count)
            {
                var indices = stack.ToArray().Reverse().ToArray();
                var tempDict = new Dictionary<FieldInfo, string>();
                for (var i = 0; i < indices.Length; i++)
                {
                    tempDict.Add(fields[i], dict[fields[i]][indices[i]]);
                }
                yield return tempDict;
                stack.Push(stack.Pop() + 1);
                while (stack.Peek() >= dict[fields[stack.Count - 1]].Count)
                {
                    stack.Pop();
                    if (stack.Count == 0)
                    {
                        yield break;
                    }
                    var old = stack.Peek();
                    stack.Pop();
                    stack.Push(old + 1);
                }
            }
        }
    }