private void writeNodes(ConfigurationNode to, Collection<Node> nodes) {
        ConfigurationNode permissionsSection = ConfigurationNode.root();

        // ensure for CombinedConfigurateStorage that there's at least *something*
        // to save to the file even if it's just an empty list.
        if (this instanceof CombinedConfigurateStorage) {
            permissionsSection.setValue(Collections.emptyList());
        }

        ConfigurationNode parentsSection = ConfigurationNode.root();
        ConfigurationNode prefixesSection = ConfigurationNode.root();
        ConfigurationNode suffixesSection = ConfigurationNode.root();
        ConfigurationNode metaSection = ConfigurationNode.root();

        for (Node n : nodes) {
            // just add a string to the list.
            if (this.loader instanceof YamlLoader && isPlain(n)) {
                if (n instanceof InheritanceNode) {
                    parentsSection.appendListNode().setValue(((InheritanceNode) n).getGroupName());
                    continue;
                }
                if (!NodeType.META_OR_CHAT_META.matches(n)) {
                    permissionsSection.appendListNode().setValue(n.getKey());
                    continue;
                }
            }

            if (n instanceof ChatMetaNode<?, ?> && n.getValue()) {
                // handle prefixes / suffixes
                ChatMetaNode<?, ?> chatMeta = (ChatMetaNode<?, ?>) n;

                ConfigurationNode attributes = ConfigurationNode.root();
                attributes.getNode("priority").setValue(chatMeta.getPriority());
                writeAttributesTo(attributes, n, false);

                switch (chatMeta.getMetaType()) {
                    case PREFIX:
                        appendNode(prefixesSection, chatMeta.getMetaValue(), attributes, "prefix");
                        break;
                    case SUFFIX:
                        appendNode(suffixesSection, chatMeta.getMetaValue(), attributes, "suffix");
                        break;
                    default:
                        throw new AssertionError();
                }
            } else if (n instanceof MetaNode && n.getValue()) {
                // handle meta nodes
                MetaNode meta = (MetaNode) n;

                ConfigurationNode attributes = ConfigurationNode.root();
                attributes.getNode("value").setValue(meta.getMetaValue());
                writeAttributesTo(attributes, n, false);

                appendNode(metaSection, meta.getMetaKey(), attributes, "key");
            } else if (n instanceof InheritanceNode && n.getValue()) {
                // handle group nodes
                InheritanceNode inheritance = (InheritanceNode) n;

                ConfigurationNode attributes = ConfigurationNode.root();
                writeAttributesTo(attributes, n, false);

                appendNode(parentsSection, inheritance.getGroupName(), attributes, "group");
            } else {
                // handle regular permissions and negated meta+prefixes+suffixes
                ConfigurationNode attributes = ConfigurationNode.root();
                writeAttributesTo(attributes, n, true);

                appendNode(permissionsSection, n.getKey(), attributes, "permission");
            }
        }

        if (permissionsSection.isList() || this instanceof CombinedConfigurateStorage) {
            to.getNode("permissions").setValue(permissionsSection);
        } else {
            to.removeChild("permissions");
        }

        if (parentsSection.isList()) {
            to.getNode("parents").setValue(parentsSection);
        } else {
            to.removeChild("parents");
        }

        if (prefixesSection.isList()) {
            to.getNode("prefixes").setValue(prefixesSection);
        } else {
            to.removeChild("prefixes");
        }

        if (suffixesSection.isList()) {
            to.getNode("suffixes").setValue(suffixesSection);
        } else {
            to.removeChild("suffixes");
        }

        if (metaSection.isList()) {
            to.getNode("meta").setValue(metaSection);
        } else {
            to.removeChild("meta");
        }
    }
Saves a configuration node to the given location

@param location the location
@param name the name of the object
@param node the node
@throws IOException if an io error occurs
common/src/main/java/me/lucko/luckperms/common/storage/implementation/file/AbstractConfigurateStorage.java