public List<Map.Entry<Integer, String>> getNodeEndings() {
        if (this.children == null) {
            return Collections.emptyList();
        }

        List<Map.Entry<Integer, String>> results = new ArrayList<>();
        for (Map.Entry<String, ImmutableTreeNode> node : this.children.entrySet()) {
            String value = node.getKey();

            // add self
            results.add(Maps.immutableEntry(0, value));

            // add child nodes, incrementing their level & appending their prefix node
            results.addAll(node.getValue().getNodeEndings().stream()
                    .map(e -> Maps.immutableEntry(
                            e.getKey() + 1, // increment level
                            // add this node's key infront of the child value
                            value + "." + e.getValue())
                    )
                    .collect(Collectors.toList()));
        }
        return results;
    }
Gets the node endings of each branch of the tree at this stage

The key represents the depth of the node.

@return the node endings
common/src/main/java/me/lucko/luckperms/common/treeview/ImmutableTreeNode.java