private static void redactAclLevel(ConfigSectionNode level, bool cascadePub) { //1 Check visibility var visibility = level.Of(ACL_LEVEL_VISIBILITY_ATTRIBUTE).ValueAsEnum(cascadePub ? AclLevelVisibility.PubCascade : AclLevelVisibility.None); if (visibility == AclLevelVisibility.None) { level.Delete(); return; } //2 Process this level var effectiveAccessLevel = level.Of(ACL_LEVEL_OVERRIDE_ATTRIBUTE, AccessLevel.CONFIG_LEVEL_ATTR).ValueAsInt(0); level.DeleteAllAttributes(); if (effectiveAccessLevel > 0) { level.AddAttributeNode(AccessLevel.CONFIG_LEVEL_ATTR, effectiveAccessLevel); } //3 Loop through all child nodes foreach (var child in level.Children) { redactAclLevel(child, visibility == AclLevelVisibility.PubCascade); } }