def _find_ancestors(individual, index):
    """
    Find the ancestors of the node at the given index.
    :param individual: The individual to find the nodes in.
    :param index: The index of the node to find the ancestors of.
    :return: A list of indices that represent the ancestors.
    """
    visited = 0
    ancestors = []
    for j in reversed(range(index)):
        arity = individual[j].arity
        if arity > visited:
            ancestors.append(j)
            visited = 0
        else:
            visited = (visited - arity) + 1
    return ancestors