This class could be simplified a lot by making it an abstract class with template methods, and making a subclass each for HDocument and HProjectIteration that just implement the different behaviour. This would allow most of the conditionals to be removed and allow all fields to be guaranteed non-null.