How to implement a multiple tree?

Bingo, that’s it.

and there is a very little error in the output

# the output
%TestNode{
  children: %{
    "" => %TestNode{
      children: %{
        "2" => %TestNode{
          children: %{
            "3" => %TestNode{
              children: %{
                "5" => %TestNode{children: %{}, path: "/2/3/5"},
                "7" => %TestNode{children: %{}, path: "/2/3/7"},
                "8" => %TestNode{children: %{}, path: "/2/3/8"}
              },
              path: "/2/3"
            },
            "4" => %TestNode{
              children: %{"6" => %TestNode{children: %{}, path: "/2/4/6"}},
              path: "/2/4"
            }
          },
          path: "/2/3"
        }
      },
      path: "/2/3"
    }
  },
  path: nil
}

for a better view, i did some change to the below

%TestNode{
  children: %{
    "" => %TestNode{
      children: %{
        "2" => %TestNode{
          children: %{
            "3" => %TestNode{children: %{},path: "/2/3"},
            "4" => %TestNode{children: %{},path: "/2/4"}},
          path: "/2/3"}
      },
      path: "/2/3"
    }
  },
  path: nil
}

as we see, the right structure may like this

%TestNode{
  children: %{
    "2" => %TestNode{
      children: %{
        "3" => %TestNode{children: %{},path: "/2/3"},
        "4" => %TestNode{children: %{},path: "/2/4"}},
      path: "/2"
    }
  },
  path: nil
}

I’m trying to fix it.

as this approach has adjusted the default order, i will try to sort them when traveling.