def find_by_id(self, id: Union[int, str], find_type: Optional[str]=None):
""" Finds UMLPackage, UMLClass, UMLEnumeration or UMLInstance object with specified Id
Looks for classes part of this package and all sub-packages
"""
if str(self.id) == str(id) and find_type in (None, "package"):
return self
for cls in self.classes:
if str(cls.id) == str(id) and find_type in (None, "class"):
return cls
for ins in self.instances:
if str(ins.id) == str(id) and find_type in (None, "instance"):
return ins
for enum in self.enumerations:
if str(enum.id) == str(id) and find_type in (None, "enumeration"):
return enum
for child in self.children:
res = child.find_by_id(id, find_type)
if res is not None:
return res