add function to apply rules to element and all children