def extract(s, start):
    """Given a string and index position to the first '(', extract a full group up to its ')'."""
    level = 1
    for idx in range(start+1, len(s)):
        ch = s[idx]
        if ch == '(':
            level += 1
        if ch == ')':
            level -= 1
        if level == 0:
            return s[start:idx+1]
    # should never get here
    raise ValueError('ill-formed string: {}'.format(s))