added a helper method to convert Function<Element,Object> to T if possible.