The attached patch solves the NullPointerException. It returns null, when the input was null. That does not seem to break anything in the code.
Looks good - I'm guessing the error was occurring when the list was empty so could have also checked for '.isEmpty()'.
Signed commit is on my new accepted branch: cdk-1.4.x-accepted
Can't change the milestone to accepted
Applied and pushed into cdk-1.4.x.