If flag = True Then For Each nd As WinForm.TreeNode In e.node.nodes If nd.Nodes.Count > 0 Then flag = False End If Next Else For Each nd1 As WinForm.TreeNode In e.Sender.AllNodes If e.node.FullName.StartsWith(nd1.FullName) = False Then nd1.Collapse End If Next End If