Long () { long partialDuration = 0; boolean durationOfChildrenIsUnknown = true; for (SMTestProxy child : getChildren()) { final Long duration = child.getDuration(); if (duration != null) { durationOfChildrenIsUnknown = false; partialDuration += duration.longValue(); } } // Lets convert partial duration in integer object. Negative partial duration // means that duration of all children is unknown return durationOfChildrenIsUnknown ? null : partialDuration; }