<!--
{
  "documentType" : "article",
  "framework" : "SpriteKit",
  "identifier" : "/documentation/SpriteKit/accessing-and-modifying-the-node-tree",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Accessing and Modifying the Node Tree"
}
-->

# Accessing and Modifying the Node Tree

See the objects and functions you use to control the node tree’s composition.

## Discussion

You create the node tree by creating parent-child relationships between nodes. Each node maintains an ordered list of children, referenced by reading the node’s `children` property. The order of the children in the tree affects many aspects of scene processing, including hit testing and rendering, so it’s important to organize the node tree appropriately.

|Method                                                                         |Description                                                                    |
|-------------------------------------------------------------------------------|-------------------------------------------------------------------------------|
|``doc://com.apple.spritekit/documentation/SpriteKit/SKNode/addChild(_:)``      |Adds a node to the end of the receiver’s list of child nodes.                  |
|``doc://com.apple.spritekit/documentation/SpriteKit/SKNode/insertChild(_:at:)``|Inserts a child into a specific position in the receiver’s list of child nodes.|
|``doc://com.apple.spritekit/documentation/SpriteKit/SKNode/removeFromParent()``|Removes the receiving node from its parent.                                    |

When you need to directly traverse the node tree, you use the properties in the following table to uncover the tree’s structure.

|Property                                                             |Description                                                                                                                              |
|---------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|
|``doc://com.apple.spritekit/documentation/SpriteKit/SKNode/children``|The array of ``doc://com.apple.spritekit/documentation/SpriteKit/SKNode`` objects that are the receiving node’s children.                |
|``doc://com.apple.spritekit/documentation/SpriteKit/SKNode/parent``  |If the node is a child of another node, this property holds the parent. Otherwise, it holds `nil`.                                       |
|``doc://com.apple.spritekit/documentation/SpriteKit/SKNode/scene``   |If the node is included anywhere in a scene, this property returns the scene node that is the root of the tree. Otherwise it holds `nil`.|

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)