Selector logic and finding matching css rules for a node