Q: Walking a list of inheritance For a game, we have a list of ranks, e.g default, mod, jrmod, admin etc. Each rank is stored in a database and contains some info just as what it inherits, and its permissions. Each rank can also inherit from another, for example, admin inherits srmod, which inherits mod, which inherits jrmod, which inherits default. This allows for permissions to be stacked without data duplication.
The issue is that currently when ranks are loaded, a user rank is set, and then that rank's inherits and loaded, and then those inherit. However, this means that the permission inheritance only goes 2 deep. For our example above, admin inherits srmod, which inherits mod. Then it stops.
I am lost as to what sort of algorithm I could use to walk down the line of inheritances, and load these permissions. This code is in Java, and each rank can have multiple inherits, e.g jrmod inherits default and lord rank.

A: You just need to check in a while loop if the Rank has an inheritance and as long as it has one get their permissions of that rank and then check again and ...
List<String> permissions = new 
Rank rank = getRank(player);
while (rank.hasInheritance()) {
  rank = rank.getInheritance();
  permissions.addAll(rank.getPermissions());
}

