@staticmethod
def prune_address_space(address_space, sorted_addresses=None):
    """Prune the address space."""
    if sorted_addresses is None:
        sorted_addresses = sorted(address_space, key=len)
    for address in sorted_addresses:
        if address.is_root or address.get_parent() in address_space:
            continue
        else:
            del address_space[address]
