public T handleValue(ValueHandler<T> valueHandler,
			Map<Object, QueryBuilder<?>> proxyQueryBuilders,
			Iterator<MethodCall> iterator, Object param) {
		TorpedoProxy proxy;
		QueryBuilder queryBuilder;
		Selector selector;

		if (param instanceof Query) {
			Query query = (Query) param;
			selector = query;
			queryBuilder = (QueryBuilder) param;
			proxy = (TorpedoProxy) query.getProxy();
		} else if (param instanceof Function) {
			Function function = (Function) param;
			selector = function;
			proxy = (TorpedoProxy) function.getProxy();
			queryBuilder = proxyQueryBuilders.get(proxy);

		} else if (param instanceof TorpedoProxy) {
			proxy = (TorpedoProxy) param;
			queryBuilder = proxyQueryBuilders.get(proxy);
			selector = new ObjectSelector(queryBuilder);
		} else {

			MethodCall methodCall = iterator.next();
			iterator.remove();
			proxy = methodCall.getProxy();
			queryBuilder = proxyQueryBuilders.get(proxy);
			selector = new SimpleMethodCallSelector(queryBuilder, methodCall);
		}

		return valueHandler.handle(proxy, queryBuilder, selector);
	}