public void refreshSmartTraceTreeView()
        {
            tvSmartTrace.Nodes.Clear();
            if (tvSmartTrace.Tag == null)
            {
                return;
            }
            var fviFindingViewItem = (FindingViewItem)tvSmartTrace.Tag;

            if (fviFindingViewItem.fFinding.Trace != null)
            {
                //String sNodeText = fviFindingViewItem.fFinding.caller_name;
                String sNodeText = "O2 Trace";
                //(fviFindingViewItem.fFinding.caller_name != null) ? fviFindingViewItem.fFinding.caller_name : o2.analysis.Analysis.getStringIndexValue(UInt32.Parse(fviFindingViewItem.fFinding.caller_name_id), fviFindingViewItem.oadO2AssessmentDataOunceV6);
                var tnRootNode = new TreeNode(sNodeText);
                tnRootNode.Tag = fviFindingViewItem.fFinding;
                AnalysisUtils.addCallsToNode_Recursive(fviFindingViewItem.fFinding.Trace, tnRootNode,
                                                       fviFindingViewItem.oadO2AssessmentDataOunceV6, stfSmartTraceFilter);
                tvSmartTrace.Nodes.Add(tnRootNode.Nodes[0]);
                tvSmartTrace.ExpandAll();
                if (ascx_SelectVisiblePanels1.getCheckBox(4).Checked)
                {
                    ascx_Glee1.setAssessmentData(fviFindingViewItem.oadO2AssessmentDataOunceV6);
                    ascx_Glee1.addTreeNodeToComboxWithNodesToPlot(tvSmartTrace.Nodes[0], fviFindingViewItem.fFinding,
                                                                  fviFindingViewItem.oadO2AssessmentDataOunceV6);
                    //   the way the Smart traces are build we want to add the 2nd child
                    ascx_Glee1.showLoadedTracesInGleeViewer();
                }
            }

            ascx_SourceCodeEditor1.gotoLine(
                fviFindingViewItem.oadO2AssessmentDataOunceV6.dFindings[fviFindingViewItem.fFinding].filename,
                (Int32)fviFindingViewItem.fFinding.line_number);
        }
        public static bool addCompatibleTracesToNode_recursive(TreeNode tnTargetNode, FindingViewItem fviFindingViewItem,
                                                               O2TraceBlock_OunceV6 otbO2TraceBlockOunceV6OfToProcess,
                                                               String sMode,
                                                               Dictionary <String, O2TraceBlock_OunceV6> dRawData)
        //TreeView tvRawData)
        {
            //TreeNode tnParentNode = O2Forms.getRootNode(tnTargetNode);
            //int iNumberOfNodes = tnParentNode.GetNodeCount(true);
            var iNumberOfNodes = O2Forms.getRootNode(tnTargetNode).GetNodeCount(true);

            if (O2Forms.getRootNode(tnTargetNode).GetNodeCount(true) > 1500)
            {
                DI.log.info(String.Format("Max number of subnodes reached (250), aborting this root node: {0}",
                                          O2Forms.getRootNode(tnTargetNode).Text));
                return(false);
            }
            if (new StackTrace().FrameCount > 50)
            {
                DI.log.info(String.Format("Max StackTrace reached (50), aborting this leaf:{0}", tnTargetNode.Text));
                return(false);
            }

            var tnTreeFor_Root = new TreeNode();

            AnalysisUtils.addCallsToNode_Recursive(fviFindingViewItem.fFinding.Trace, tnTreeFor_Root,
                                                   fviFindingViewItem.oadO2AssessmentDataOunceV6,
                                                   Analysis.SmartTraceFilter.MethodName);
            if (sMode == "Sinks")
            {
                // first add the normal sinks
                foreach (AssessmentAssessmentFileFinding fFinding in otbO2TraceBlockOunceV6OfToProcess.dSinks.Keys)
                {
                    var tnTreeFor_ChildTrace            = new TreeNode();
                    var fviFindingViewItemForChildTrace = new FindingViewItem(fFinding,
                                                                              fFinding.vuln_name ?? OzasmtUtils_OunceV6.getStringIndexValue(
                                                                                  UInt32.Parse(
                                                                                      fFinding.vuln_name_id),
                                                                                  otbO2TraceBlockOunceV6OfToProcess.
                                                                                  dSinks[fFinding]), null,
                                                                              otbO2TraceBlockOunceV6OfToProcess.dSinks[fFinding
                                                                              ]);
                    AnalysisUtils.addCallsToNode_Recursive(fviFindingViewItemForChildTrace.fFinding.Trace,
                                                           tnTreeFor_ChildTrace,
                                                           fviFindingViewItemForChildTrace.oadO2AssessmentDataOunceV6,
                                                           Analysis.SmartTraceFilter.MethodName);

                    TreeNode tnRootNode_Sink = getTreeNodeOfTraceType_recursive(tnTreeFor_Root,
                                                                                TraceType.Known_Sink);
                    TreeNode tnRootNode_Source = getTreeNodeOfTraceType_recursive(tnTreeFor_ChildTrace,
                                                                                  TraceType.Source);


                    if (AreNodesCompatible(tnRootNode_Sink, tnRootNode_Source))
                    {
                        String sNodeText = getUniqueSignature(fFinding, TraceType.Known_Sink,
                                                              otbO2TraceBlockOunceV6OfToProcess.dSinks[fFinding], true);

                        // ensures we don't add the same source more that once per line (needs to be more optimized
                        List <String> ltnAllNodesAddedSofar = O2Forms.getStringListWithAllParentNodesText(tnTargetNode);
                        if (false == ltnAllNodesAddedSofar.Contains(sNodeText))
                        {
                            if (sNodeText != tnTargetNode.Text) // don't add if the child call is the same as the parent
                            {
                                tnTargetNode.Nodes.Add(O2Forms.newTreeNode(sNodeText, sNodeText, 0,
                                                                           fviFindingViewItemForChildTrace));
                            }
                            if (sNodeText == null)
                            {
                                return(false);
                            }
                        }
                    }
                }
                // then add the Glued Sinks

                foreach (AssessmentAssessmentFileFinding fFinding in otbO2TraceBlockOunceV6OfToProcess.dGluedSinks.Keys)
                {
                    var fviFindingViewItemForChildTrace = new FindingViewItem(fFinding,
                                                                              fFinding.vuln_name ?? OzasmtUtils_OunceV6.getStringIndexValue(
                                                                                  UInt32.Parse(
                                                                                      fFinding.vuln_name_id),
                                                                                  otbO2TraceBlockOunceV6OfToProcess.
                                                                                  dGluedSinks[fFinding]), null,
                                                                              otbO2TraceBlockOunceV6OfToProcess.dGluedSinks[
                                                                                  fFinding]);
                    String sNodeText = getUniqueSignature(fFinding, TraceType.Known_Sink,
                                                          otbO2TraceBlockOunceV6OfToProcess.dGluedSinks[fFinding], true);
                    tnTargetNode.Nodes.Add(O2Forms.newTreeNode(sNodeText, sNodeText, 0, fviFindingViewItemForChildTrace));
                }
            }
            foreach (TreeNode tnChildNode in tnTargetNode.Nodes)
            {
                //   int iNodeCount = tnChildNode.GetNodeCount(true);
                //    DI.log.info(iNodeCount + "   " + tnChildNode.Text);
                //if (tvRawData.Nodes[tnChildNode.Text] != null)
                if (dRawData.ContainsKey(tnChildNode.Text))
                {
                    // (now back to false) was true (check side effects)
                    if (false ==
                        addCompatibleTracesToNode_recursive(tnChildNode, (FindingViewItem)tnChildNode.Tag,
                                                            dRawData[tnChildNode.Text],
                                                            //                (O2TraceBlock_OunceV6) tvRawData.Nodes[tnChildNode.Text].Tag,
                                                            "Sinks", dRawData))
                    {
                        //tvRawData))
                        return(false);
                    }
                }
            }
            return(true);
        }