docs: def substitute(progression, substitute_index, depth=0):
      """Give a list of possible substitutions for progression[substitute_index].
  
      If depth > 0 the substitutions of each result will be recursively added
      as well.
  
      Example:
      >>> substitute(['I', 'IV', 'V', 'I'], 0)
      ['III', 'III7', 'VI', 'VI7', 'I7']
      """
      res = []
      simple_substitutions = [
          ('I', 'III'),
          ('I', 'VI'),
          ('IV', 'II'),
          ('IV', 'VI'),
          ('V', 'VII'),
          ('V', 'VIIdim7'),
          ('V', 'IIdim7'),
          ('V', 'IVdim7'),
          ('V', 'bVIIdim7'),
          ]
      p = progression[substitute_index]
      (roman, acc, suff) = parse_string(p)
  
      # Do the simple harmonic substitutions
      if suff == '' or suff == '7':
          for subs in simple_substitutions:
              r = None
              if roman == subs[0]:
                  r = subs[1]
              elif roman == subs[1]:
                  r = subs[0]
              if r != None:
                  res.append(tuple_to_string((r, acc, '')))
  
                  # Add seventh or triad depending on r
                  if r[-1] != '7':
                      res.append(tuple_to_string((r, acc, '7')))
                  else:
                      res.append(tuple_to_string((r[:-1], acc, '')))
  
      if suff == '' or suff == 'M' or suff == 'm':
          res.append(tuple_to_string((roman, acc, suff + '7')))
  
      if suff == 'm' or suff == 'm7':
          n = skip(roman, 2)
          a = interval_diff(roman, n, 3) + acc
          res.append(tuple_to_string((n, a, 'M')))
          res.append(tuple_to_string((n, a, 'M7')))
  
      # Major to minor substitution
      if suff == 'M' or suff == 'M7':
          n = skip(roman, 5)
          a = interval_diff(roman, n, 9) + acc
          res.append(tuple_to_string((n, a, 'm')))
          res.append(tuple_to_string((n, a, 'm7')))
  
      if suff == 'dim7' or suff == 'dim':
          # Add the corresponding dominant seventh
          res.append(tuple_to_string((skip(roman, 5), acc, 'dom7')))
  
          n = skip(roman, 1)
          res.append(tuple_to_string((n, acc + interval_diff(roman, n, 1),
              'dom7')))
  
          # Add diminished chord
          last = roman
          for x in range(4):
              next = skip(last, 2)
              acc += interval_diff(last, next, 3)
              res.append(tuple_to_string((next, acc, suff)))
              last = next
      res2 = []
      if depth > 0:
          for x in res:
              new_progr = progression
              new_progr[substitute_index] = x
              res2 += substitute(new_progr, substitute_index, depth - 1)
      return res + res2