moved ClearActiveAnalysisTreeBranches to the thread writing to file