Use recursive generics to match entities