'Recursively lists the node and nodes linked to it.
Depth 0 returns a list with the node.
Depth 1 returns a list with the node and all the directly linked nodes.
Depth 2 includes the linked nodes\' links, and so on.'

def flatten(self, depth=1, traversable=(lambda node, edge: True), _visited=None):

    _visited = (_visited or {})
    _visited[self.id] = (self, depth)
    if (depth >= 1):
        for n in self.links:
            if ((n.id not in _visited) or (_visited[n.id][1] < (depth - 1))):
                if traversable(self, self.links.edges[n.id]):
                    n.flatten((depth - 1), traversable, _visited)
    return [n for (n, d) in _visited.values()]
