diff --git a/src/hooked_containers/common.py b/src/hooked_containers/common.py index 99bdc90..fd8883b 100644 --- a/src/hooked_containers/common.py +++ b/src/hooked_containers/common.py @@ -44,3 +44,12 @@ class HookedContainer(ABC, Sized, Iterable[T], Container[T]): @abstractmethod def insert(self, index, value): ... + + # Custom Methods + + def get_nested(self, keys): + """Recursively call __getitem__ with each key in the iterable.""" + result = self + for key in keys: + result = result[key] + return result