I think this should be:

if ( resolveIds || (!resolveIds && skeletonRoots.size() == 0))

and a comment added:
// if joint is referenced by Id, or if there is not skeleton information, then search everywhere