I've got it working now, so I'll post what my RelationPredicateBucket looks like if anyone else needs it.
relationPredicateBucket.Relations.Add(new EntityRelation(LibraryItemFields.LibraryItemId, LibraryItemFields.LibraryItemId, RelationType.OneToOne), "LI1", JoinHint.None);
GroupByCollection groupByCollection = new GroupByCollection(LibraryItemFields.RootLibraryItemId);
groupByCollection.HavingClause = new PredicateExpression();
groupByCollection.HavingClause.Add(LibraryItemFields.Version.SetObjectAlias("LI1") == LibraryItemFields.Version.SetAggregateFunction(AggregateFunction.Max));
groupByCollection.HavingClause.AddWithAnd(LibraryItemFields.RootLibraryItemId.SetObjectAlias("LI1") == LibraryItemFields.RootLibraryItemId);
relationPredicateBucket.PredicateExpression.Add(
new FieldCompareSetPredicate(
null, null, LibraryItemFields.RootLibraryItemId, null,
SetOperator.Exist, null, null, "", 0, null, false, groupByCollection)
);
Only thing I don't really like is the 1:1 relation I had to create to the same table, but I guess that's unavoidable. If in any way it can be avoided, please let me know.