code: def _check_branching(X,Xsamples,restart,threshold=0.25):
      
      check = True
      if restart == 0:
          Xsamples.append(X)
      else:
          for Xcompare in Xsamples:
              Xtmax_diff = np.absolute(X[-1,:] - Xcompare[-1,:])
              # If the second largest element is smaller than threshold
              # set check to False, i.e. at least two elements
              # need to change in order to have a branching.
              # If we observe all parameters of the system,
              # a new attractor state must involve changes in two
              # variables.
              if np.partition(Xtmax_diff,-2)[-2] < threshold:
                  check = False
          if check:
              Xsamples.append(X)
      if not check:
          logg.m('realization {}:'.format(restart), 'no new branch', v=4)
      else:
          logg.m('realization {}:'.format(restart), 'new branch', v=4)
      return check, Xsamples
docs: \
      Check whether time series branches.
  
      Parameters
      ----------
      X (np.array): current time series data.
      Xsamples (np.array): list of previous branching samples.
      restart (int): counts number of restart trials.
      threshold (float, optional): sets threshold for attractor
          identification.
  
      Returns
      -------
      check : bool
          true if branching realization
      Xsamples
          updated list