# Cannot read property 'traverse' of undefined when traverse object in scene and remove it

**URL:** <https://discourse.threejs.org/t/cannot-read-property-traverse-of-undefined-when-traverse-object-in-scene-and-remove-it/28672>\
**Category:** Questions\
**Tags:** object3d\
**Created:** [August 5, 2021, 10:06am UTC](https://discourse.threejs.org/t/cannot-read-property-traverse-of-undefined-when-traverse-object-in-scene-and-remove-it/28672 "2021-08-05T10:06:10Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![mjurczyk](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mjurczyk/32/10995_2.png) [@mjurczyk](https://discourse.threejs.org/u/mjurczyk)\
**Post date:** [August 5, 2021, 10:10am UTC](https://discourse.threejs.org/t/cannot-read-property-traverse-of-undefined-when-traverse-object-in-scene-and-remove-it/28672/2 "2021-08-05T10:10:14Z")

</div>

As per [docs](https://threejs.org/docs/?q=object#api/en/core/Object3D.traverse) - you should not add / remove / modify any elements when using `Object3D.traverse`. If you need to do that - you can use `children.forEach` or save referenced to the elements you’d like to remove in an array outside of the traverse callback.

> Note: Modifying the scene graph inside the callback is discouraged.

---

_[View the full topic](https://discourse.threejs.org/t/cannot-read-property-traverse-of-undefined-when-traverse-object-in-scene-and-remove-it/28672)._
