def _parse_string(s):
    """Parse a string representation of a tree structure (implementation)
    
    Nodes are separated by whitespace, while child lists are enclosed in
    balanced parentheses.
    
    Return value is a tuple of (tree_structure, length_in_characters)"""
    if '(' not in s:
        s, _, _ = s.partition(')')
        return tuple(s.split()), len(s)
    i = s.index('(')
    j = s.index(')')
    if j < i:
        return _parse_string(s[:j])
    b, n = _parse_string(s[i+1:])
    j = i + n
    a = tuple(s[:i].split())
    c, m = _parse_string(s[j+2:])
    return a + (b,) + c, j+2+m