How to check if a child has a specific parent

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lalel345

how to know which parent has a child

:bust_in_silhouette: Reply From: Ertain

Why not check the node’s parent against the node you’re trying to find?

if desired_parent == child.get_parent():
    print("desired_parent is the parent of child.")

You can also check for the name of the parent:

if child.get_parent().get_name() == "correct parent":
   print("The correct parent is found.")