Matching JSON nodes in Javascript