is_equal and map adapted from lodash