private static function buildAndDisplayAdUnitTree(
        AdUnit $root,
        array $adUnits
    ) {
        if (is_null($root)) {
            print "No root unit found.\n";

            return;
        }

        $treeMap = [];

        foreach ($adUnits as $adUnit) {
            $parentId = $adUnit->getParentId();

            if (!is_null($parentId)) {
                if (!array_key_exists($parentId, $treeMap)) {
                    $treeMap[$parentId] = [];
                }

                $treeMap[$parentId][] = $adUnit;
            }
        }

        self::displayInventoryTree($root, $treeMap);
    }