Optimize dom diff algorithm to O(md) where d is the edit distance