I've stumbled on a problem that goes above my skill level. 

Find the unique atom(s) and their counts for any supplied chemical formula, such as K4(ON(SO3)2)2. -- What I'm asking for right here. 

I've gathered that recursion and/or dynamic programming might be required (or at least useful) for this problem.

Here's how far I've gotten:

```py
class Solution(object):
    def __init__(self):
        self.code = []
        self.atoms = {}

    def encode_string(self,string):
        """
        Return a list of elements where 
        @'a' = alphabetical 
        @'d' = digit
        @int = parentheses, wherre number reflects nesting.

        'k4(on(so3)2)2' --> ['a', 'd', 1, 'a', 'a', 2, 'a', 'a', 'd', 2, 'd', 1, 'd']
        """

        self.string = string

        for char in string:
            if char.isalpha():
                self.code.append('a')
            elif char.isdigit():
                self.code.append('d')
            elif char == '(':
                self.code.append('l') #left parenthesis 
            else:
                self.code.append('r') #right parenthesis 

        self.pars = [elem for elem in self.code if elem in ['r','l']]

        self.par_structure = []
        count = 1
        for idx, elem in enumerate(self.pars):
            if elem == 'l':
                self.par_structure.append(count)
                count += 1
            elif elem == 'r':
                count -= 1
                self.par_structure.append(count)

        count = 0        
        for idx, char in enumerate(self.code):
            if char in ['l','r']:
                self.code[idx] = self.par_structure[count]
                count += 1        

    def id_atoms(self):
        self.indices = [idx for idx,elem in enumerate(self.code) if elem == 0]
        for idx in self.indices:
            atom = self.string[idx]
            self.atoms[atom] = 0

    def parse_code():
        pass

```

I've listed as use case of the encode\_string method which identifies letters, digits, and parentheses by their level of depth. I think that this is progress towards a solution. The next step would be multiplying out the characters found within the parentheses by the digit value found.

Any advice would be appreciated!