'Returns a tree of nested IGTREE.Node objects,
where the given list of vectors contains (Vector, class)-tuples, and
where the given list of features is sorted by information gain ratio.'

def _tree(self, vectors=[], features=[]):

    vectors = list(vectors)
    features = list(features)
    if ((len(vectors) == 0) or (len(features) == 0)):
        return IGTreeNode()
    classes = defaultdict(int)
    for (v, type) in vectors:
        classes[type] += 1
    c = max(classes, key=classes.__getitem__)
    f = features[0]
    n = IGTreeNode(feature=f, type=c)
    if (len(classes) == 1):
        return n
    if (len(features) == 1):
        return n
    p = defaultdict(list)
    for (v, type) in vectors:
        x = (f in v)
        p[x].append((v, type))
    for x in p:
        if any(((type != c) for (v, type) in p[x])):
            n.append(self._tree(p[x], features[1:]))
            n[(-1)].value = x
    return n
