func (rn *RelationshipNode) buildLeafNodeInventory() []LeafNode {
	l := make([]LeafNode, 0)
	for _, absChld := range rn.children {
		switch chld := absChld.(type) {
		case *RelationshipNode:
			l2 := chld.buildLeafNodeInventory()
			l = append(l, l2...)
		case LeafNode:
			l = append(l, chld)
		}
	}
	return l
}
buildLeafNodeInventory visits the tree under the receiver and returns the list of the LeafNodes. This list is built
by visiting the tree recursively.
package graph
import (
	"fmt"
	"github.com/hashicorp/go-immutable-radix"
	"github.com/deckarep/golang-set"
	"net"
	"github.com/ANSSI-FR/transdep/tools"
)
func (rn *RelationshipNode) simplifyRelWithCycle() bool {
	var newChildren []Node
	modif := false
	childrenToAnalyze := rn.children[:]
	Outerloop:
	for len(childrenToAnalyze) != 0 {
		var mergedChildren []Node
		Innerloop:
		for _, chld := range childrenToAnalyze {
			if dg, ok := chld.(*RelationshipNode); ok {
				modif = dg.simplifyRelWithCycle() || modif
				if len(dg.children) == 1 {
					mergedChildren = append(mergedChildren, dg.children[0])
					modif = true
					continue Innerloop
				}
			}
			if _, ok := chld.(*Cycle); ok {
				if rn.relation == AND_REL && len(rn.children) > 1 {
					newChildren = []Node{new(Cycle)}
					modif = true
					break Outerloop
				}
			}
			newChildren = append(newChildren, chld)
		}
		childrenToAnalyze = mergedChildren
	}
	rn.children = newChildren
	return modif
}
func (rn *RelationshipNode) auxSimplifyGraph() bool {
	var newChildren []Node
	modif := false
	childrenToAnalyze := make([]Node, len(rn.children))
	copy(childrenToAnalyze, rn.children)
	for len(childrenToAnalyze) > 0 {
		var mergedChildren []Node
		for _, chldGraphNode := range childrenToAnalyze {
			if chld, ok := chldGraphNode.(*RelationshipNode); ok {
				if chld.relation == rn.relation {
					mergedChildren = append(mergedChildren, chld.children...)
					modif = true
				} else {
					newChildren = append(newChildren, chldGraphNode)
				}
			} else {
				newChildren = append(newChildren, chldGraphNode)
			}
		}
		childrenToAnalyze = make([]Node, len(mergedChildren))
		copy(childrenToAnalyze, mergedChildren)
	}
	rn.children = make([]Node, len(newChildren))
	copy(rn.children, newChildren)
	for _, chldGraphNode := range rn.children {
		if chld, ok := chldGraphNode.(*RelationshipNode); ok {
			modif = chld.auxSimplifyGraph() || modif
		}
	}
	return modif
}
func (rn *RelationshipNode) SimplifyGraph() *RelationshipNode {
	ng, ok := rn.deepcopy().(*RelationshipNode)
	if !ok {
		return nil
	}
	modif := true
	for modif {
		modif = false
		modif = ng.auxSimplifyGraph() || modif
		modif = ng.simplifyRelWithCycle() || modif
	}
	return ng
}