'Return the number of siblings of child or raise ValueError if child has no parent'

def all_sibling_count(self, child, same_type=False):

    parent = child.getparent()
    if (parent is None):
        raise ValueError(u'Child    has    no    parent')
    if same_type:
        siblings = OrderedSet(chain(child.itersiblings(preceding=False), child.itersiblings(preceding=True)))
        return len((self.element_map[self.map_tag_name(child.tag)] & siblings))
    else:
        return (len(parent) - 1)
