def traverse_naive(node, depth): print('__'*depth + node.name) for ref in node.refs: traverse_naive(ref, depth+1)