class Lutaml::Model::ComparableModel::Tree

def add_child(child)

def add_child(child)
  @children << child
end

def colorize(text, color)

def colorize(text, color)
  return text unless color
  color_codes = { red: 31, green: 32, blue: 34 }
  "\e[#{color_codes[color]}m#{text}\e[0m"
end

def initialize(content, color: nil)

def initialize(content, color: nil)
  @content = content
  @children = []
  @color = color
end

def to_s(indent = "", is_last = true)

def to_s(indent = "", is_last = true)
  prefix = is_last ? "└── " : "├── "
  result = "#{indent}#{colorize(prefix + @content, @color)}\n"
  @children.each_with_index do |child, index|
    is_last_child = index == @children.size - 1
    child_indent = indent + (if is_last
                               "    "
                             else
                               "#{colorize('│',
                                           @color)}   "
                             end)
    result += child.to_s(child_indent, is_last_child)
  end
  result
end