Corrects the method for removing unnecessary nodes from node list
Refactors the code, moves the behavior to the link function of the directive and of course, adds some bugs...