DefaultDevice device = null;
// First check in the hierarchy to see if the device exists.
Hierarchy hierarchy = loadHierarchy();
final HierarchyEntry entry = hierarchy.find(deviceName);
if (entry != null) {
// The device name exists in the hierarchy.
// Create the device by reading in it's standard and custom
// polices, and also any device patterns and device TACs.
device = createDevice(deviceName);
// We must explicitly add the fallback policy for backward
// compatibility.
final HierarchyEntry parent = entry.getParent();
String fallbackDeviceName;
if (parent != null) {
fallbackDeviceName = parent.getDeviceName();
} else {
// for backwards compatibility with the old JDOM accessor,
// we add a fallback of null for Master. Not sure if we
// really should?
fallbackDeviceName = null;