bool InitializeBrushMeshInstances()
        {
            var instances = brushContainerAsset ? brushContainerAsset.Instances : null;

            // TODO: figure out why this can happen (mess around with spiral stairs)
            // TODO: does this have anything to do with spiral stairs not updating all submeshes when being modified?
            if (instances != null &&
                instances.Length !=
                brushContainerAsset.SubMeshCount)
            {
                brushContainerAsset.UpdateInstances();
                instances = brushContainerAsset ? brushContainerAsset.Instances : null;
            }

            var requiredNodeLength = RequiredNodeLength(instances);

            if (Nodes != null && Nodes.Length == requiredNodeLength)
            {
                if (Nodes.Length == 0)
                {
                    var brush = (CSGTreeBrush)Nodes[0];
                    brush.BrushMesh = BrushMeshInstance.InvalidInstance;
                    brush.Operation = CSGOperationType.Additive;
                }
                else
                if (Nodes.Length == 1)
                {
                    var brush = (CSGTreeBrush)TopNode;
                    brush.BrushMesh = brushContainerAsset.Instances[0];
                    brush.Operation = brushContainerAsset.Operations[0];
                }
                else
                {
                    for (int i = 0; i < instances.Length; i++)
                    {
                        var brush = (CSGTreeBrush)Nodes[i + 1];
                        brush.BrushMesh = brushContainerAsset.Instances[i];
                        brush.Operation = brushContainerAsset.Operations[i];
                    }
                }
                return(true);
            }
            else
            {
                bool needRebuild = (Nodes != null && instances != null && instances.Length > 0) && Nodes.Length != requiredNodeLength;
                if (Nodes.Length <= 1)
                {
                    var brush = (CSGTreeBrush)TopNode;
                    if (brush.BrushMesh != BrushMeshInstance.InvalidInstance)
                    {
                        brush.BrushMesh = BrushMeshInstance.InvalidInstance;
                        brush.Operation = CSGOperationType.Additive;
                    }
                }
                else
                {
                    for (int i = 1; i < Nodes.Length; i++)
                    {
                        var brush = (CSGTreeBrush)Nodes[i];
                        if (brush.BrushMesh != BrushMeshInstance.InvalidInstance)
                        {
                            brush.BrushMesh = BrushMeshInstance.InvalidInstance;
                            brush.Operation = CSGOperationType.Additive;
                        }
                    }
                }
                if (needRebuild) // if we don't do this, we'll end up creating nodes infinitely, when the node can't make a valid brushMesh
                {
                    CSGNodeHierarchyManager.RebuildTreeNodes(this);
                }
                return(false);
            }
        }