def _read_phy_line(line):
    """
    Reads a single comma-separated line from phylotree and returns the
    indentation level, the haplogroup id, and variants. Importantly, some nodes
    do not have IDs, so we need to check that we do not accidentally grab the
    variant list instead of the blank id.

    Args:
        line: A string representing 1 line in CSV phylotree input
    Returns:
        level: The level of the node this line represents in the tree.
               (the number of blank fields before the haplogroup ID)
        hap_id: The haplogroup ID for this entry (can be '')
        variants: List of variant strings for this node.
    """
    items = line.decode('utf-8').rstrip().split(',')
    level = 0
    while items[level] == '':
        level += 1
    hap_id = items[level]
    while ' ' in hap_id:
        level -= 1
        hap_id = items[level]
    variants = items[level + 1].split()
    return level, hap_id, variants