private function explodeChildren($id, array $childrenMap)
    {
        if (! isset($childrenMap[$id])) {
            return [];
        }

        // Indexing items by their value
        $indexed = [];

        foreach ($childrenMap[$id] as $childName) {
            $indexed[$childName] = $childName;
        }

        return array_map(
            function ($childId) use ($childrenMap) {
                return $this->explodeChildren($childId, $childrenMap);
            },
            $indexed
        );
    }
private function explodeChildren($id, array $childrenMap)
    {
        if (! isset($childrenMap[$id])) {
            return [];
        }

        // Indexing items by their value
        $indexed = [];

        foreach ($childrenMap[$id] as $childName) {
            $indexed[$childName] = $childName;
        }

        return array_map(
            function ($childId) use ($childrenMap) {
                return $this->explodeChildren($childId, $childrenMap);
            },
            $indexed
        );
    }
private function explodeChildren ( $ id , array $ childrenMap ) { if ( ! isset ( $ childrenMap [ $ id ] ) ) { return [ ] ; } // Indexing items by their value $ indexed = [ ] ; foreach ( $ childrenMap [ $ id ] as $ childName ) { $ indexed [ $ childName ] = $ childName ; } return array_map ( function ( $ childId ) use ( $ childrenMap ) { return $ this -> explodeChildren ( $ childId , $ childrenMap ) ; } , $ indexed ) ; }
Retrieves all children of a given element, recursively
Must be given a childrenMap for performance reasons

@param string $id
@param array  $childrenMap

@return array
Retrieves all children of a given element recursively Must be given a childrenMap for performance reasons