modify walk_pair to parse complex keys