$flowSequences =
$this->
buildHierarchyTree($flowSequences);
$flatBag =
new ArrayStruct();
$sequences =
[];
foreach ($flowSequences as $flowSequence) { if ($flowSequence['sequence_id'
] === null
) { continue;
} $sequences[] =
$this->
createNestedSequence($flowSequence,
[],
$flatBag);
} /** @var array<string, Sequence> $flat */
$flat =
$flatBag->
all();
return new Flow($id,
$sequences,
$flat);
} private function buildHierarchyTree(array
$flowSequences, ?string
$parentId = null
): array
{ $children =
[];