improve _set_rule_for_parents function
add tests for set_rule_for_parents