def _check_children(node):
 for child in node.get_children():
  ok = False
  if (child is None):
   print(('Hm, child of %s is None' % node))
   continue
  if (not hasattr(child, 'parent')):
   print((' ERROR: %s has child %s %x with no parent' % (node, child, id(child))))
  elif (not child.parent):
   print((' ERROR: %s has child %s %x with parent %r' % (node, child, id(child), child.parent)))
  elif (child.parent is not node):
   print((' ERROR: %s %x has child %s %x with wrong parent %s' % (node, id(node), child, id(child), child.parent)))
  else:
   ok = True
  if (not ok):
   print('lines;', node.lineno, child.lineno)
   print('of module', node.root(), node.root().name)
   raise AstroidBuildingException
  _check_children(child)

def _check_children ( node ) : for child in node . get_children ( ) : ok = False if ( child is None ) : print ( ( 'Hm, child of %s is None' % node ) ) continue if ( not hasattr ( child , 'parent' ) ) : print ( ( ' ERROR: %s has child %s %x with no parent' % ( node , child , id ( child ) ) ) ) elif ( not child . parent ) : print ( ( ' ERROR: %s has child %s %x with parent %r' % ( node , child , id ( child ) , child . parent ) ) ) elif ( child . parent is not node ) : print ( ( ' ERROR: %s %x has child %s %x with wrong parent %s' % ( node , id ( node ) , child , id ( child ) , child . parent ) ) ) else : ok = True if ( not ok ) : print ( 'lines;' , node . lineno , child . lineno ) print ( 'of module' , node . root ( ) , node . root ( ) . name ) raise AstroidBuildingException _check_children ( child )
a helper function to check children - parent relations .