private function checkCycles(
        array $configuration,
        $node,
        array &$nodesVisited
    ) {
        if (in_array($node, $nodesVisited)) {
            if (!$this->canBeCyclic) {
                throw new CyclesNotAllowedException();
            }

            return $this;
        }

        $nodesVisited[] = $node;

        foreach ($configuration as $transitionConfiguration) {
            if ($transitionConfiguration[0] === $node) {
                $this->checkCycles(
                    $configuration,
                    $transitionConfiguration[2],
                    $nodesVisited
                );
            }
        }

        return $this;
    }