':type words: List[str]
:rtype: str'

def alienOrder(self, words):

    (result, zero_in_degree_queue, in_degree, out_degree) = ([], collections.deque(), {}, {})
    nodes = sets.Set()
    for word in words:
        for c in word:
            nodes.add(c)
    for i in xrange(1, len(words)):
        if ((len(words[(i - 1)]) > len(words[i])) and (words[(i - 1)][:len(words[i])] == words[i])):
            return ''
        self.findEdges(words[(i - 1)], words[i], in_degree, out_degree)
    for node in nodes:
        if (node not in in_degree):
            zero_in_degree_queue.append(node)
    while zero_in_degree_queue:
        precedence = zero_in_degree_queue.popleft()
        result.append(precedence)
        if (precedence in out_degree):
            for c in out_degree[precedence]:
                in_degree[c].discard(precedence)
                if (not in_degree[c]):
                    zero_in_degree_queue.append(c)
            del out_degree[precedence]
    if out_degree:
        return ''
    return ''.join(result)
