'Check ancestors of node for soft roots'

def find_ancestors_and_remove_children(self, node, nodes):

    if node.parent:
        if node.parent.attr.get('soft_root', False):
            nodes = node.parent.get_descendants()
            node.parent.parent = None
            nodes = ([node.parent] + nodes)
        else:
            nodes = self.find_ancestors_and_remove_children(node.parent, nodes)
    else:
        for newnode in nodes:
            if ((newnode != node) and (not newnode.parent)):
                self.find_and_remove_children(newnode, nodes)
    for child in node.children:
        if (child != node):
            self.find_and_remove_children(child, nodes)
    return nodes
