'Apply inline patterns to a parsed Markdown tree.
Iterate over ElementTree, find elements with inline tag, apply inline
patterns and append newly created Elements to tree.  If you don\'t
want process your data with inline paterns, instead of normal string,
use subclass AtomicString:
node.text = markdown.AtomicString("data won\'t be processed with inline patterns")
Arguments:
* markdownTree: ElementTree object, representing Markdown tree.
Returns: ElementTree object with applied inline patterns.'

def run(self, tree):

    self.stashed_nodes = {}
    stack = [tree]
    while stack:
        currElement = stack.pop()
        insertQueue = []
        for child in currElement.getchildren():
            if (child.text and (not isinstance(child.text, markdown.AtomicString))):
                text = child.text
                child.text = None
                lst = self.__processPlaceholders(self.__handleInline(text), child)
                stack += lst
                insertQueue.append((child, lst))
            if child.getchildren():
                stack.append(child)
        for (element, lst) in insertQueue:
            if element.text:
                element.text = markdown.inlinepatterns.handleAttributes(element.text, element)
            i = 0
            for newChild in lst:
                if newChild.tail:
                    newChild.tail = markdown.inlinepatterns.handleAttributes(newChild.tail, element)
                if newChild.text:
                    newChild.text = markdown.inlinepatterns.handleAttributes(newChild.text, newChild)
                element.insert(i, newChild)
                i += 1
    return tree
