def dfs(self, seq, cur, result):
        """
        checking done by the parent (making debug much easier by preventing going one more step)
        structure of dfs
        1. terminal condition
        2. for loop for dfs candidates
        3. condition check for candidates
        :param seq:
        :param cur:
        :param result:
        :return:
        """
        # terminal condition
        if not seq and len(cur)==4:
            result.append(".".join(cur))
            return

        # for i in xrange(1, 3+1):
        # for loop
        for i in xrange(1, min(3, len(seq))+1):
            new_seg = seq[:i]
            # condition check
            if len(cur)<4 and self.is_valid(new_seg):
                self.dfs(seq[i:], cur+[new_seg], result)
            else:
                return
dataset/ETHPy150Open algorhythms/LeetCode/093 Restore IP Addresses.py/Solution.dfs/original