def _parse_joint(self, bvh, token_index):
    end_site = False
    joint_id = bvh[token_index][1]
    token_index = (token_index + 1)
    joint_name = bvh[token_index][1]
    token_index = (token_index + 1)
    parent_name = self._get_bone_context()
    if (joint_id == 'End'):
        joint_name = (parent_name + '_Nub')
        end_site = True
    joint = self._new_bone(parent_name, joint_name)
    if (bvh[token_index][0] != 'OPEN_BRACE'):
        print('Was expecting brance, got ', bvh[token_index])
        return None
    token_index = (token_index + 1)
    (offsets, token_index) = self._read_offset(bvh, token_index)
    joint['offsets'] = offsets
    if (not end_site):
        (channels, token_index) = self._read_channels(bvh, token_index)
        joint['channels'] = channels
        for channel in channels:
            self._motion_channels.append((joint_name, channel))
    self._skeleton[joint_name] = joint
    self._skeleton[parent_name]['children'].append(joint_name)
    while (((bvh[token_index][0] == 'IDENT') and (bvh[token_index][1] == 'JOINT')) or ((bvh[token_index][0] == 'IDENT') and (bvh[token_index][1] == 'End'))):
        self._push_bone_context(joint_name)
        token_index = self._parse_joint(bvh, token_index)
        self._pop_bone_context()
    if (bvh[token_index][0] == 'CLOSE_BRACE'):
        return (token_index + 1)
    print('Unexpected token ', bvh[token_index])
def _parse_joint(self, bvh, token_index):
    end_site = False
    joint_id = bvh[token_index][1]
    token_index = (token_index + 1)
    joint_name = bvh[token_index][1]
    token_index = (token_index + 1)
    parent_name = self._get_bone_context()
    if (joint_id == 'End'):
        joint_name = (parent_name + '_Nub')
        end_site = True
    joint = self._new_bone(parent_name, joint_name)
    if (bvh[token_index][0] != 'OPEN_BRACE'):
        print('Was expecting brance, got ', bvh[token_index])
        return None
    token_index = (token_index + 1)
    (offsets, token_index) = self._read_offset(bvh, token_index)
    joint['offsets'] = offsets
    if (not end_site):
        (channels, token_index) = self._read_channels(bvh, token_index)
        joint['channels'] = channels
        for channel in channels:
            self._motion_channels.append((joint_name, channel))
    self._skeleton[joint_name] = joint
    self._skeleton[parent_name]['children'].append(joint_name)
    while (((bvh[token_index][0] == 'IDENT') and (bvh[token_index][1] == 'JOINT')) or ((bvh[token_index][0] == 'IDENT') and (bvh[token_index][1] == 'End'))):
        self._push_bone_context(joint_name)
        token_index = self._parse_joint(bvh, token_index)
        self._pop_bone_context()
    if (bvh[token_index][0] == 'CLOSE_BRACE'):
        return (token_index + 1)
    print('Unexpected token ', bvh[token_index])