def buildDSAndSpeciesTree(self): """Build one valid DS-tree for the relationships given, and a species tree with which it is consistent, and returns both trees. If no such pair of trees can be built, returns False instead. The DS-tree built prioritizes dups first. """ startcc = self.genes.copy() dstree = TreeNode() dstree.set = set(startcc) dsNodeList =[dstree] constructedSpeciesTree = TreeNode() constructedSpeciesTree.set = set(self.treelessGeneSpeciesMapping[x] for x in startcc) hasPassed = self._buildDSAndSpeciesTree(startcc, dsNodeList, constructedSpeciesTree) #Return dstree and species tree as an ordered pair treepair = [dstree, constructedSpeciesTree] #in case you are wondering, what's below is (hasPassed ? treepair : False) return (treepair if hasPassed else False)