code: def graph_growth(
      graph: OptGraph,
      node_parent: OptNode,
      node_factory: PipelineOptNodeFactory,
      requirements: PipelineComposerRequirements,
      max_depth: int,
  ):
      """Function create a graph and links between nodes"""
      offspring_size = randint(
          requirements.min_arity, requirements.max_arity
      )
  
      for offspring_node in range(offspring_size):
          height = distance_to_root_level(graph, node_parent)
          is_max_depth_exceeded = height >= max_depth - 2
          is_primary_node_selected = height < max_depth - 1
          is_growth_should_stopped = (
              random.random()
              > RandomPipelineFactory.PROBABILITY_OF_GROWTH
          )
          if (
              is_max_depth_exceeded
              or is_primary_node_selected
              or is_growth_should_stopped
          ):
              primary_node = node_factory.get_node(is_primary=True)
              node_parent.nodes_from.append(primary_node)
              graph.add_node(primary_node)
          else:
              secondary_node = node_factory.get_node(is_primary=False)
              graph.add_node(secondary_node)
              node_parent.nodes_from.append(secondary_node)
              graph_growth(
                  graph,
                  secondary_node,
                  node_factory,
                  requirements,
                  max_depth,
              )
  
file_path: FEDOT/fedot/core/pipelines/random_pipeline_factory.py
imports: import random
  from copy import deepcopy
  from random import randint
  from typing import Optional
  from golem.core.constants import MAX_GRAPH_GEN_ATTEMPTS
  from golem.core.dag.graph_utils import distance_to_root_level
  from golem.core.dag.graph_verifier import GraphVerifier
  from golem.core.optimisers.graph import OptGraph, OptNode
  from golem.core.optimisers.random_graph_factory import RandomGraphFactory
  from fedot.core.pipelines.pipeline_composer_requirements import PipelineComposerRequirements
  from fedot.core.pipelines.pipeline_node_factory import PipelineOptNodeFactory
label_desc: Use image node_id 3 for calling a global function with example usage: graph_growth(graph, node_parent, node_factory, requirements, max_depth) without return types