def smart_split(search, string):
  """Split string while maintaining blocks encapsulated by brackets."""
  result = []
  open_brackets = 0
  last_split = 0
  for i, char in enumerate(string):
    if char == '(':
      open_brackets += 1
    elif char == ')':
      open_brackets -= 1
    elif open_brackets <= 0 and char == search:
      result.append(string[last_split:i])
      last_split = i + 1
  result.append(string[last_split:])
  return result