def __getitem__(self, key):
if isinstance(key, int):<EOL><INDENT>for node in self.__nodes:<EOL><INDENT>if node.node_id == key:<EOL><INDENT>return node<EOL><DEDENT><DEDENT><DEDENT>for node in self.__nodes:<EOL><INDENT>if node.name == key:<EOL><INDENT>return node<EOL><DEDENT><DEDENT>raise KeyError<EOL>
Return node by name or by index.