def METHOD_NAME(string):
    """Find the position of next comma in the string.
    If no ',' is found in the string, return the string length. All
    chars inside '()' and '[]' are treated as one element and thus ','
    inside these brackets are ignored.
    """
    assert (string.count('(') == string.count(')')) and (
        string.count('[')
        == string.count(']')), f'Imbalanced brackets exist in {string}'
    end = len(string)
    for idx, char in enumerate(string):
        pre = string[:idx]
        # The string before this ',' is balanced
        if ((char == ',') and (pre.count('(') == pre.count(')'))
                and (pre.count('[') == pre.count(']'))):
            end = idx
            break
    return end